Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a shell script to identify the given string is
palindrome or not?

Answer Posted / manuswami

len=0
i=1
tag=0
echo -n "Enter a String: "
read str
len=`echo $str | wc -c`
len=`expr $len - 1`
halfLen=`expr $len / 2`

while [ $i -le $halfLen ]

do
c1=`echo $str|cut -c$i`
c2=`echo $str|cut -c$len`
if [ $c1 != $c2 ] ; then
i=$halfLen
tag=1
fi
i=`expr $i + 1`
len=`expr $len - 1`
done


if [ $tag -eq 0 ]

then
echo "String is Palindrome"
else
echo "String is not Palindrome"

fi

Is This Answer Correct ?    87 Yes 35 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is batch file programming?

1202


What is the equivalent of a file shortcut that we have a window on a linux system?

1176


write a shell script to generate a alert ? like when ur birthday came then generate a alert ur birthday is today like that ?

4184


What is a shell environment?

1042


What is shift command in shell script?

1090


What is the difference between scripting and coding?

1096


How will you emulate wc –l using awk?

1597


What are script files?

1070


What will happen to my current process when I execute a command using exec?

1127


What does egrep mean?

1024


What is scripting used for?

1092


Why do we use shell scripting?

1037


Is shell scripting useful?

1101


How does ls command work?

1078


What is the meaning of $1 in shell script?

1159