You are on page 1of 1

MONESH R LAB EXP 9

|20BTRCA023| Write a program to take string as


command line argument and reverse it.

CODE:

read -p ”Insert a string: ” str


reversed_string=""
len=${#str}
for ((i=$len-1; i>=0; i--))
do
reversed_string="$reversed_string$
{str:$i:1}"
done
echo "$reversed_string"

You might also like