write a shell script to identify the given string is
palindrome or not?

Answer Posted / gaurav shah

clear
echo enter a string
read a
b=`expr $a | wc -c`
b=`expr $b - 1`
echo number of letter=$b
while test $b -gt 0
do
e=`expr $a | cut -c $b`
d=$d$e
b=`expr $b - 1`
done
echo the reversed string is :$d
if test $a = $d
then
echo it is a palindrome
else
echo it is not a palindrome
fi

Is This Answer Correct ?    54 Yes 21 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the zombie processes?

641


on “sed” command EmpData(Sample Database) 1122|j.b. saxena |g.m. |account |12/12/52|6000 2233|n.k. gupta |d.g.m |sales |31/12/40|9000 4545|anil agarwal |director |account |06/07/47|7500 5656|lalit choudhury |executive|marketing|07/09/50|5000 1265|chanchal singhvi|g.m. |admin |12/09/63|6000 0110|shyam saksena |chairman |marketing|12/12/43|8000 5566|jai sharma |director |account |23/12/89|7000 7733|jayant |d.g.m |sales |29/02/70|6000 1. From the above database substitute the delimiter of first 3 lines with “ : “ 2. From the above database substitute the delimiter with “ : ” 3. Insert the string “ XYZ Employees” in the first line. 4. Store the lines pertaining to the directors, d.g.m and g.m into three separate files. 5. Using address store first 4 lines into a file Empupdate. 6. Find the pattern “account” in the database and replaces that with “accounts”. 7. Select those lines which do not have a pattern “g.m”. 8. Insert a blank line after every line in the database.

2707


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

709


Why is shell scripting important?

654


What is bash shell command?

622






What is awk script?

605


Explain about echo command?

715


I have 2 files and I want to print the records which are common to both.

799


How can the contents of a file inside jar be read without extracting in a shell script?

701


Explain about the exit command?

657


What is option in shell script?

630


What are different types of shell?

577


What does .sh file contain?

635


What are scripts in psychology?

675


What is scripting autism?

784