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 get the last line from a file using just the terminal?
What is inside a seashell?
Which is better perl or shell scripting?
What exactly is a shell?
Write a shell script to get current date, time, user name and current working directory.
What does the sh command do?
What's the difference between scripting and coding?
What is bash used for?
Is shell a part of kernel?
Is shell scripting useful?
What is the best shell scripting language?
What is a shell in operating system?
What does it mean to debug a script?
How to print pid of the current shell?
What is subshell?