shell script code to reverse number


echo "Enter the Number"
read n1
rev=0
a=0
while [ $n1 -gt "0" ]
do
mod=`expr $n1 % 10`
rev=`expr $rev \* 10 + $mod`
n1=`expr $n1 / 10`

done
echo "$rev"

/* OUTPUT
linux-ogus:~> ./reverse_no
Enter the Number
654
456
*/

0 comments :