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 cmd a shell?
What language is bash written in?
What is shell chemistry?
What is shell environment?
What is batch file programming?
What is difference between shell and bash scripting?
How to find all the files modified in less than 3 days and save the record in a text file?
What does echo mean in scripting?
What is a boot block?
How to get the 3rd element/column from each line from a file?
What command needs to be used to take the backup?
What are the different commands available to check the disk usage?
Why are there shells on the beach?
Why do we write bin bash in shell scripts?
How do I stop script errors?