Just check out the script...
Code:
1 #!/bin/bash
2
3 echo -n "Enter a string :: "
4 read str
5 echo -n "Reverse is :: "
6 l=`expr length "$str"`
7 while [ $l -ge 1 ]
8 do
9 m=`echo $str | cut -c "$l"`
10 echo -n $m
11 l=`expr $l - 1`
12 done
13 echo
It takes a script and shows it in reverse manner.
it works well for single word input like..
Quote:
[user31@FEDORA ~]$ sh exmp5.sh
Enter a string :: asit
Reverse is :: tisa
|
But ignores the white space if multi-word is entered...
Quote:
[user31@FEDORA ~]$ sh exmp5.sh
Enter a string :: qutub asit
Reverse is :: tisabutuq
|
How can I fix this ??