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
How to use arguments in a script?
How will you pass and access arguments to a script in linux?
What is sed in shell script?
How to set an array in linux?
How do you find out What is your shell?
What is the use of a shebang line?
What is the lifespan of a variable inside a shell script?
What is the conditional statement in shell scripting?
How to print all array elements and their respective indexes?
How do I run a script from command prompt?
What are the two files of crontab command?
How to find all the files modified in less than 3 days and save the record in a text file?
What are different types of shell?
What is the first line in a shell script?
Explain about non-login shell files?