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

Explain about stdin, stdout and stderr?

637


What is bash shell command?

562


Which scripting language is best for automation?

536


How many fields are present in a crontab file and what does each field specify?

590


determine the output of the following command: echo ${new:-variable}

551






What are types of shells?

554


What is the equivalent of a file shortcut that we have a window on a linux system?

610


What is the first line in every perl script called?

559


What is an inode block?

579


Explain about echo command?

626


How do I run a shell script in powershell?

556


How will you print the login names of all users on a system?

577


What is bash eval?

552


How do you debug a script?

569


What is @echo off?

571