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 program to check wheather a given string is
pallindrome or not?

Answer Posted / goutamkumar

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 ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between bash and shell?

1169


What does it mean to debug a script?

1094


How can any user find out all information about a specific user like his default shell, real-life name, default directory, when and how long he has been using the system?

1157


What are script files?

1068


How do I open the shell prompt?

1241


What are the different types of commonly used shells on a typical linux system?

1166


How would you compare the strings in a shell script?

1030


What is shell terminal?

997


How will you find the 99th line of a file using only tail and head command?

2579


How do I start a shell script?

1283


Explain about "s" permission bit in a file?

1119


Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.

1209


What are the default permissions of a file when it is created?

1066


What is an sh file?

986


What is subshell?

989