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?
Give some situations where typing error can destroy a program?
What are the disadvantages of shell scripting?
How to pass an argument to a script?
Write the syntax for "if" conditionals in linux?
What is option in shell script?
c program the catches the ctrl-c(SIGINT) Signal for the first time and prints a output rather and exit on pressing Ctrl-C again
How will you print the login names of all users on a system?
What is the best shell scripting language?
Write down the syntax for all the loops in shell scripting.
Why is a script important?
What is a command line shell?
What is a program shell?
What is a scripting language simple definition?
How will you emulate wc –l using awk?