bab123
1
Hi,
I have to write a shell script that converts numbers in to words
below is what i wrote.My script is not running.
-----------------------------------
echo -n "Enter number : "
read n
len= echo $n | wc -c
echo " number in words : "
for ( i=1; i<len; i++ )
do
num=echo $n | cut -c i
case num in
0\) echo -n "zero " ;;
1\) echo -n "one " ;;
2\) echo -n "two " ;;
3\) echo -n "three " ;;
4\) echo -n "four " ;;
5\) echo -n "five " ;;
6\) echo -n "six " ;;
7\) echo -n "seven " ;;
8\) echo -n "eight " ;;
9\) echo -n "nine " ;;
esac
done
---------------------------
Some one please correct me
Thanks in Advance
bab123
pludi
2
echo -n "Enter number : "
read n
len= echo $n | wc -c
echo " number in words : "
for ( i=1; i<len; i++ )
do
num=echo $n | cut -c i
case $num in
0) echo -n "zero " ;;
1) echo -n "one " ;;
2) echo -n "two " ;;
3) echo -n "three " ;;
4) echo -n "four " ;;
5) echo -n "five " ;;
6) echo -n "six " ;;
7) echo -n "seven " ;;
8) echo -n "eight " ;;
9) echo -n "nine " ;;
esac
done
bab123
3
Pludi,
Thanks for the reply
But i ma gettimng the following error
-n Enter number :
876
4
number in words :
sam.sh: syntax error at line 6: `(' unexpected
bab123
4
Any help?
why i am getting the error in for loop line?
Don't use the for loop...Try using other loops...
Is this homework?