write a shell program to check wheather a given string is
pallindrome or not?
Answer Posted / goutamkumar
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 ? | 6 Yes | 1 No |
Post New Answer View All Answers
Is shell a scripting language?
When should shell programming/scripting not be used?
What is awk script?
What is another name for a bash shell script that you might see?
Differentiate between ‘ and ” quotes.
What are the zombie processes?
what is info area how many types?
What language is shell scripting?
What are types of shells?
What does $@ mean bash?
Why is it called a shell?
How do I open a jshell in cmd?
How does path variable work?
What are the 3 standard streams in linux?
What does it mean to debug a script?