write a shell script to identify the given string is
palindrome or not?
Answer Posted / purbasha jana
echo "Enter number : "
read n
# store single digit
sd=0
# store number in reverse order
rev=""
# store original number
on=$n
while [ $n -gt 0 ]
do
sd=$(( $n % 10 )) # get Remainder
n=$(( $n / 10 )) # get next digit
# store previous number and current digit in reverse
rev=$( echo ${rev}${sd} )
done
if [ $on -eq $rev ];
then
echo "Number is palindrome"
else
echo "Number is NOT palindrome"
fi
| Is This Answer Correct ? | 10 Yes | 12 No |
Post New Answer View All Answers
What is the default shell of solaris?
How do I open the shell prompt?
Which scripting language is best for automation?
Where is bash history?
How can I send a mail with a compressed file as an attachment?
What shell is bin sh?
What are the types of script?
how to get part of string variable with echo command only?
What is the significance of the shebang line in shell scripting?
How can we find the process name from its process id?
How to print all array elements and their respective indexes?
What is bash command used for?
Is bash an operating system?
How will you pass and access arguments to a script in linux?
How do I run a script from command prompt?