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

Answer Posted / shashank gonte

#!/bin/sh

if [ $# -eq 1 ] #accept input through as parameter to #
command
then
echo $1 > temporary.txt #store input to a file

if [ `cat temporary.txt` = `rev temporary.txt` ]
then
echo -e "\n\n$1 is pelindrome\n\n"
else
echo -e "\n\n$1 is not pelindrome\n\n"
fi

rm temporary.txt #remove temporary created file
else #input validation for only one parameter accepted
echo -e "\n\ninvalid no of argument please enter
only one string argument\n\n"
exit 0
fi

Is This Answer Correct ?    0 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to get the last line from a file using just the terminal?

674


What is inside a seashell?

649


Which is better perl or shell scripting?

566


What exactly is a shell?

608


Write a shell script to get current date, time, user name and current working directory.

642






What does the sh command do?

612


What's the difference between scripting and coding?

599


What is bash used for?

581


Is shell a part of kernel?

564


Is shell scripting useful?

596


What is the best shell scripting language?

544


What is a shell in operating system?

593


What does it mean to debug a script?

575


How to print pid of the current shell?

606


What is subshell?

532