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 are the different variables present in linux shell?
What are script files?
What is shell and shell script?
What is the use of .sh file?
Is bash an operating system?
What is web script?
How would you compare the strings in a shell script?
What is the fastest scripting language?
What is shell prompt?
How to find all the files modified in less than 3 days and save the record in a text file?
What is the purpose of scripting?
What are the zombie processes?
What exactly is a shell?
What happens on a system call?
Determine the output of the following command: name=shubham && echo ‘my name is $name’.