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

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

571


What language is bash?

489


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.

1707


How can I send a mail with a compressed file as an attachment?

556


how will you find the total disk space used by a specific user?

578






What is shell company all about?

574


What is a shell made of?

556


How to get script name inside a script?

547


What is scripting autism?

701


Why is the use of shell script?

542


How do I read a .sh file?

529


What are script files?

548


How do I debug a shell script?

562


What is the best scripting language?

562


What is eval in shell script?

650