Write a Shell script to accept a string as a command-line argument and reverse the same.
Code:
str=$1
b=`echo $str|wc -c`
l=`expr $b - 1`
echo Length of String is $l
a=" "
for (( i=l ; i>0 ; i-- ))
do
c=`echo $str|cut -c $i`
a=$a$c
done
echo $a
Output:
Tags:
Shell Script