write a shell script to identify the given string is
palindrome or not?
Answer Posted / siva
echo "PALINDROME NUMBER"
echo "ENTER THE NUMBER :"
read n
n1=$n
rev=0
while [ $n1 -ne 0 ]
do
rem=`expr $n1 % 10`
n1=`expr $n1 / 10`
rev=`expr $rem + $rev \* 10`
done
if [ $n -eq $rev ]
then
echo $n is a Palindrome Number
else
echo $n is not a Palindrome Number
fi
PALINDROME NUMBER
ENTER THE NUMBER :
121
121 is a Palindrome Number
$sh palno.sh
PALINDROME NUMBER
ENTER THE NUMBER :
123
123 is not a Palindrome Number
| Is This Answer Correct ? | 24 Yes | 7 No |
Post New Answer View All Answers
What command needs to be used to take the backup?
What does it mean by #!/Bin/sh or #!/Bin/bash at the beginning of every script?
Is powershell a bash?
Why do we write bin bash in shell scripts?
What is the difference between break and continue commands?
In my bash shell I want my prompt to be of format '$"present working directory":"hostname"> and load a file containing a list of user-defined functions as soon as I log in, how will you automate this?
What is web script?
What is the use of break command?
How do I edit a .sh file?
How to print pid of the current shell?
What is the default shell of solaris?
What is shell and terminal?
What are the different types of commonly used shells on a typical linux system?
What is the equivalent of a file shortcut that we have a window on a linux system?
What is the significance of the shebang line in shell scripting?