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
Calculate a real number calculation directly from the terminal and not any shell script.
Why are there shells on the beach?
Explain about return code?
Is shell scripting useful?
What is scripting autism?
Why is it called a shell?
What is echo $shell?
What is shell company all about?
Explain about login shell?
What does echo $0 do?
What is bash eval?
Explain about the slow execution speed of shells?
What is .sh file in mac?
What are scripts in psychology?
Explain about "s" permission bit in a file?