BASH Script to Check if a number is Armstrong or Not
- by atif089
Hi, I was writing a script to check if a number is Armstrong or not. This is my Code
echo "Enter Number"
read num
sum=0
item=$num
while [ $item -ne 0 ]
do
rem='expr $item % 10'
cube='expr $rem \* $rem \* $rem'
sum='expr $sum + $cube'
item='expr $item / 10'
done
if [ $sum -eq $num ]
then
echo "$num is an Amstrong Number"
else
echo "$num is not an Amstrong Number"
fi
After I run this script,
$ ./arm.sh
I always get this error
./arm.sh: line 5: [: too many arguments
./arm.sh: line 12: [: too many arguments
I am on cygwin.