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 to get the first line from a file using just the terminal?

595


What are the various stages of a linux process it passes through?

624


What does the sh command do?

604


i have 2 tables 4 colums table 1 respective values a1 6, a2 8,a3 9,a4 14 & table 2 respective values a1 6, a2 8, a3 9, a4 12. if compare 2 tables 3 colums values same then 4th column values 1)Qes diff >5 then (5 * diff value ) 2)Qes diff <5 the 5 3)Qes diff 5 then 5 print respective values..

1787


What is shell chemistry?

535






How do I read a .sh file?

529


What is scripting autism?

700


What is bash command used for?

579


What are the different commands available to check the disk usage?

489


What happens on a system call?

558


What is awk script?

543


How do I run a .sh file?

613


What is $1 in shell scripting?

589


What does $@ mean in shell?

590


What is the difference between scripting and coding?

535