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 / gaurav shah.ait

tput clear

echo -e "Enter String :- \c"
read str
len=`expr $str|wc -m `
len=`expr $len - 1`
len1=`expr $len `
echo -e "Reverse String :- \c"
while [ $len -ne 0 ]
do
s1=` expr $str|cut -c$len `
echo -e "$s1\c "
len=` expr $len - 1 `
done
len=`expr $str|wc -m `
len=`expr $len - 1`
echo ""
n=1
flag=0
while [ $len -ne 0 ]
do
fst=` expr $str|cut -c$n `
lst=` expr $str|cut -c$len `
len=` expr $len - 1 `
n=` expr $n + 1`

if test $fst != $lst
then
flag=1
fi
done
if test $flag = 1
then
echo "Given String Is Not Palindrome"
else
echo "Given String Is Palindrome"
fi

Is This Answer Correct ?    16 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

determine the output of the following command: echo ${new:-variable}

991


Explain about shebang?

1044


Devise a script that takes file name as arguement(which must present in the current directory)and locates from your home directory tree all thpath names of its links.Then mail the list to self.

2225


What are the zombie processes?

983


madhar chod unix ke 10 commands dhang se likh nahi sakta hai

3484


What lives in a shell?

972


Is bash a shell script?

1072


How to get the first line from a file using just the terminal?

1131


I want to connect to a remote server and execute some commands, how can I achieve this?

1030


Calculate a real number calculation directly from the terminal and not any shell script.

1231


What does egrep mean?

974


How to print the first array element?

1045


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

1136


Is shell scripting a programming language?

1061


How do I stop script errors?

1145