How to print the reverse of number n entered by user
Linux Bash Script
echo "Input the string without space"
read str
for i in $(seq 0 ${#str}) ; do
revstr=${str:$i:1}$revstr
done
echo "The given string is " $str
echo "Its reverse is " $revstr
if [ "$str" = "$revstr" ]; then
echo "It is a palindrome."
else
echo "It is not a palindrome."
fi
Execute the Linux Script
./9_palindrome_or_not.sh
Output of Linux Script
Input the string without space malayalam The given string is malayalam Its reverse is malayalam It is a palindrome.