Shell Script to find if a String is Palindrome or not




A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward.

Like "MADAM" this string will be same if we reverse the characters.
Note: An empty string and any single characters are palindromes by default.



Script:


echo "input your string without space"
read vstr
for i in $(seq 0 ${#vstr})
do
rvstr=${vstr:$i:1}${rvstr}
done

echo "Input string was :" $vstr
echo "After reversng string is :" $rvstr

if [ "$vstr" = "$rvstr" ]
then
echo "String is palindrome."
else
echo "String is not plaindrome."
fi




If you like please follow and comment