Shell Script to find if a String is Palindrome or not
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
Post a Comment
Post a Comment