| Home > Source Code > Shell Script |
|
| Shell Script |
| |
Shell script to check whether a String is Palindrome or not?
This Shell Script is developed using Bourne Shell.
1=0
cnt=1
tag=0
echo "Enter a String?"
read str
1 =`echo $str |wc -c`
1 =`expr $l - 1`
1h=`expr $l / 2`
while [ $cnt -le $lh ]
do
c1=`echo $str|cut -c$cnt`
c2=`echo $str|cut -c$l`
if [ $c1 != $c2 ]
then
cnt=$lh
tag=1
fi
cnt=`expr $cnt + 1`
=`expr $l - 1`
done
if [ $tag -eq 0 ]
then
echo "String is Palindrome"
else
echo “String is not Palindrome”
fi |
| |
|