# Shell script to find whether an input number is palindrome or not

in Categories Academic, Shell Math last updated April 12, 2008

A palindrome is a word, phrase, number or other sequence of units that has the property of reading the same in either direction (the adjustment of punctuation and spaces between words is generally permitted). Composing literature in palindromes is an example of constrained writing. The word “palindrome” was coined from Greek roots palin (“back”) and dromos (“way, direction”) by English writer Ben Jonson in the 1600s.

A palindromic number is a number where the digits, with decimal representation usually assumed, are the same read backwards, for example, 58285. They are studied in recreational mathematics where palindromic numbers with special properties are sought. A palindromic prime is a palindromic number that is a prime number.

## 11 comment

1. krishan chandra pandey says:

#check the no is palendrome or not
echo “enter the no to check palendrome”
x=0
y=0
m=\$n
while [ \$n -ne 0 ]
do
x=\$(( n % 10 ))
y=\$(( y * 10 + x ))
n=\$(( n / 10 ))
done
echo “y is \$y”
echo “number is \$m”
if [ \$m -eq \$y ]
then
echo “value is palendrome”
else
echo “value is not palendrome”
fi

2. anshul says:

#!/bin/bash
echo “Enter a String or number : ”
if [ “\$(echo \$string | rev)” = “\$string” ]
then
echo “\”\$string\” IS a Palindrome”
else
echo “\”\$strin\” IS NOT a Palindrome”

3. Nitin says:

please give a program without using rev function….
use only while loop to write a program

4. santhu says:

hi
can you provide the code for n number of inputs and n number of outputs in shell scripting for verilog code and that code is generated in another file as like .v

i ll waiting for your reply and send me as soon as possible

5. kritanta kr roy says:

jyothi you are ………. i have no word to express it ,,,u are great

6. Krutika Modi says:

echo “enter any no:”
no=`expr \$no`
no1=`expr \$no1`
rev=`expr 0`
while [ \$no -gt 0 ]
do
temp=`expr \$no % 10`
rev=`expr \$temp + \$rev \* 10`
no=`expr \$no / 10`
done
if [ \$no1 -eq \$rev ];
then
echo “\$no1 is a palindrom no”
else
echo “\$no1 is not a palindrom no”
fi

1. arun says:

nhi chal raha

7. jyothi says:

Shell script to find whether an input number is palindrome or not

Simple script for the above is
echo “Enter the string:”
rvs=`echo \$s | rev`
if [ \$s = \$rvs ]
then
echo “It is palindrome”
else
echo “It is not”
fi

1. Anonymous says:

jyothi ji ki jai ho!!!

8. buggi says: