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

Answer Posted / gaurav shah

clear
echo enter a string
read a
b=`expr $a | wc -c`
b=`expr $b - 1`
echo number of letter=$b
while test $b -gt 0
do
e=`expr $a | cut -c $b`
d=$d$e
b=`expr $b - 1`
done
echo the reversed string is :$d
if test $a = $d
then
echo it is a palindrome
else
echo it is not a palindrome
fi

Is This Answer Correct ?    54 Yes 21 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How would you compare the strings in a shell script?

543


How to find all the files modified in less than 3 days and save the record in a text file?

608


When should shell programming/scripting not be used?

588


I want to monitor a continuously updating log file, what command can be used to most efficiently achieve this?

752


Explain about stdin, stdout and stderr?

627






How to set an array in linux?

591


How do we delete all blank lines in a file?

575


What is the way to do multilevel if-else's in shell scripting?

653


Is bash an operating system?

542


Explain about return code?

632


Is shell scripting a programming language?

572


What command needs to be used to take the backup?

528


Print the 10th line without using tail and head command.

1672


What is in a script?

562


What is a batch file used for?

558