Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the different variables present in linux shell?

1041


What are script files?

969


What is shell and shell script?

1060


What is the use of .sh file?

1052


Is bash an operating system?

930


What is web script?

1029


How would you compare the strings in a shell script?

929


What is the fastest scripting language?

936


What is shell prompt?

950


How to find all the files modified in less than 3 days and save the record in a text file?

1005


What is the purpose of scripting?

1004


What are the zombie processes?

917


What exactly is a shell?

1013


What happens on a system call?

949


Determine the output of the following command: name=shubham && echo ‘my name is $name’.

929