Skip to content

string reversal

Savio Mathew edited this page Jun 18, 2019 · 1 revision
#!/bin/bash
echo -e "\n Enter the string"
read string
reverse=""
len=${#string}
for (( i=$len-1; i>=0; i-- ))
do 
	reverse="$reverse${string:$i:1}"
done
echo "$reverse"

or

echo $string | rev