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
Tell something about the super block in shell scripting?
Explain about login shell?
What is the equivalent of a file shortcut that we have a window on a linux system?
Devise a script that takes file name as arguement(which must present in the current directory)and locates from your home directory tree all thpath names of its links.Then mail the list to self.
Determine the output of the following command: name=shubham && echo ‘my name is $name’.
How do I set bash as default shell mac?
shell script for reverse the string
What does it mean by #!/Bin/sh or #!/Bin/bash at the beginning of every script?
What is computer cli?
What does .sh file contain?
Write a shell script that adds two numbers if provided as the command line argument and if the two numbers are not entered throws an error message.
What is shell geeksforgeeks?
madhar chod unix ke 10 commands dhang se likh nahi sakta hai
What is batch file programming?
Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.