Operating System Shell Scripting/Programs on Linux
Linux Shell Scripting programs
Sunday, 17 June 2012
Write a Shell script to accept a string as command line argument and reverse the same
if [ $# -gt 0 ]
then
x=`echo $1 | wc -c`
x=`expr $x - 1`
final=""
while [ $x -gt 0 ]
do
c=`echo $1 | cut -c $x`
x=`expr $x - 1`
final=$final$c
done
fi
echo Reverse string is : $final
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment