write a shell script to identify the given string is
palindrome or not?
Answer Posted / manuswami
len=0
i=1
tag=0
echo -n "Enter a String: "
read str
len=`echo $str | wc -c`
len=`expr $len - 1`
halfLen=`expr $len / 2`
while [ $i -le $halfLen ]
do
c1=`echo $str|cut -c$i`
c2=`echo $str|cut -c$len`
if [ $c1 != $c2 ] ; then
i=$halfLen
tag=1
fi
i=`expr $i + 1`
len=`expr $len - 1`
done
if [ $tag -eq 0 ]
then
echo "String is Palindrome"
else
echo "String is not Palindrome"
fi
| Is This Answer Correct ? | 87 Yes | 35 No |
Post New Answer View All Answers
What language is bash?
What is the command to find out today's date?
Is powershell a bash?
c program to display the information of given file similar to givan by the unix or linux command ls -l
How important is shell scripting?
What is the syntax of while loop in shell scripting?
Why should we use shell scripts?
What are script files?
Calculate a real number calculation directly from the terminal and not any shell script.
What is a scripting language simple definition?
What is the first line of a shell script called?
What is echo $shell?
What are the different types of commonly used shells on a typical linux system?
What are the default permissions of a file when it is created?
wats the deinitions for shell utility and filter?