| Home > Source Code > Shell Script |
|
| Shell Script |
| |
Shell script to remove all numbers that occurs more than once in an ordered array
clear
echo "Enter the number of numbers:"
read limit
count=1
echo "Enter the numbers in sorted order"
while [ $count -le $limit ]
do
eval read x$count
count=`expr $count + 1`
done
i=1
while [ $i -le $limit ]
do
eval xval = "\$x$i"
j=`expr $i + 1`
while [ $j -le $limit ]
do
eval yval="\$x$j"
if [ $xval -eq $yval ]
then
pos=j
while [ $pos -le $limit ]
do
n=`expr $pos + 1
eval x$pos=x$n
done
limit=`expr $limit -1`
i=`expr $i - 1`
fi
j=`expr $j + 1`
done
count =1
echo " The array without duplication is "
while [ $count -le $limit ]
do
eval echo "\$x$count"
count=`expr $count + 1`
done |
| |
|