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 / sudhir

#!/bin/ksh

i=1
tag=0

print -n "Enter a String:"
read str
len=`echo $str | wc -c`
if [[ $len -eq 1 ]]
then
print "Enter a valid string"
exit 2;
fi

let len=len-1
let halflen=len/2;

while [[ $i -le $halflen ]]
do
c1=`echo $str | cut -c $i`
c2=`echo $str | cut -c $len`

if [[ $c1 != $c2 ]]
then
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 ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What makes c shell a more preferable option than the bourne shell?

1019


Explain about debugging?

1078


Explain about sourcing commands?

1152


What is the best scripting language?

1075


What shell is bin sh?

1016


What is a shell in operating system?

1155


What is the command to find out users on the system?

1017


Explain how you Automate your application using Shell scripting.

2363


What is the first line of a shell script called?

1134


How to open a read-only file in the shell?

1178


What language is shell scripting?

1068


What is path in shell script?

1141


How will you print the login names of all users on a system?

1018


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

4185


wats the deinitions for shell utility and filter?

2371