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

Can you write a script to portray how set –x works?

551


How do I read a .sh file?

529


How does ls command work?

583


What is the lifespan of a variable inside a shell script?

1121


How do I run a .sh file on mac?

673






How to print all array elements and their respective indexes?

504


Why do we use shell scripting?

547


How do I open a jshell in cmd?

596


Why is used in shell scripting?

556


Write down the syntax of "for " loop

607


Explore about environment variables?

591


How do I open the shell prompt?

571


What is scripting used for?

559


What is shell and shell script?

556


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

492