Bash Shell Program-To Check Whether the string is palindrome or not

Bash Shell Program-To Check Whether the string is palindrome or not

#!bin/bash
echo "Enter The String:"
read str
len=${#str}
k=$len-1
i=0
flag=1
while [ $i -le $(($len / 2)) ]
do
s1=${str:$i:1}
s2=${str:$k-i:1}
if [ $s1 != $s2 ]
then
flag=0
fi
let i++
done
if [ $flag -eq 1 ]
then
echo "Palindrome"
else
echo "Not Palindrome"
fi

Output
Enter The String:Anandhu
Palindrome

Comments

Popular posts from this blog

Introduction to C++ Programming Language

The Assembly Process Of 8086 Microprocessor-Two Pass Assembling Steps

Installing 8086 Assembler on a Computer