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
Explain about sourcing commands?
How do I run a shell script in powershell?
What is shell geeksforgeeks?
How do I save a powershell script?
How important is shell scripting?
Is it possible to substitute "ls" command in the place of "echo" command?
What language is used in terminal?
Write the syntax for "if" conditionals in linux?
What are the 3 standard streams in linux?
shell script for reverse the string
What is the meaning of $1 in shell script?
What is scripting used for?
How to calculate the number of passed arguments?
What happens on a system call?
i have 2 tables 4 colums table 1 respective values a1 6, a2 8,a3 9,a4 14 & table 2 respective values a1 6, a2 8, a3 9, a4 12. if compare 2 tables 3 colums values same then 4th column values 1)Qes diff >5 then (5 * diff value ) 2)Qes diff <5 the 5 3)Qes diff 5 then 5 print respective values..