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 is the default shell of solaris?

1044


How do I open the shell prompt?

1204


Which scripting language is best for automation?

967


Where is bash history?

940


How can I send a mail with a compressed file as an attachment?

1042


What shell is bin sh?

976


What are the types of script?

1181


how to get part of string variable with echo command only?

1031


What is the significance of the shebang line in shell scripting?

1133


How can we find the process name from its process id?

1182


How to print all array elements and their respective indexes?

969


What is bash command used for?

1077


Is bash an operating system?

993


How will you pass and access arguments to a script in linux?

1164


How do I run a script from command prompt?

1086