日期:2014-05-16 浏览次数:20667 次
#!/bin/bash
#Reverse Order
echo "Reverse Order and print."
if [ $# -ne 1 ]
then
echo "Usage $0 number"
echo " I will find reverse order of given number."
echo " For e.g. $0 123, I will print 321."
exit 1
fi
n=$1
rev=0
sd=0
while [ $n -gt 0 ]
do
sd=`expr $n % 10`
rev=`expr $rev /* 10 + $sd`
n=`expr $n / 10`
echo "$sd $rev $n"
done
echo "Reversed number is $rev"
Reverse Order and print.
expr: syntax error
3 872
expr: syntax error
2 87
expr: syntax error
7 8
expr: syntax error
8 0
Reversed number is