A simple Unix shell script to reverse a number

n=$1

if [ $# -ne 1 ]
then
echo "Error:No. of parameter must be 1"
else
echo "Reverse of $1 is "
while [ $n -gt 0 ]
do
c=$(($n % 10))
echo -n "$c"
n=$(($n / 10))
done
echo ""
fi

Popular Posts