Shell script to accept a string as command line argument and reverse the same.

 


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:


AJ Blogs

Hello everyone, My name Arth and I like to write about what I learn. Follow My Website - https://sites.google.com/view/aj-blogs/home

Post a Comment

Previous Post Next Post
Best Programming Books

Facebook

AJ Facebook
Checkout Our Facebook Page
AJ Blogs
Checkout Our Instagram Page