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
Explain about stdin, stdout and stderr?
What is bash shell command?
Which scripting language is best for automation?
How many fields are present in a crontab file and what does each field specify?
determine the output of the following command: echo ${new:-variable}
What are types of shells?
What is the equivalent of a file shortcut that we have a window on a linux system?
What is the first line in every perl script called?
What is an inode block?
Explain about echo command?
How do I run a shell script in powershell?
How will you print the login names of all users on a system?
What is bash eval?
How do you debug a script?
What is @echo off?