Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 use arguments in a script?

1110


How will you pass and access arguments to a script in linux?

1160


What is sed in shell script?

1059


How to set an array in linux?

1239


How do you find out What is your shell?

1063


What is the use of a shebang line?

1200


What is the lifespan of a variable inside a shell script?

1661


What is the conditional statement in shell scripting?

1239


How to print all array elements and their respective indexes?

968


How do I run a script from command prompt?

1085


What are the two files of crontab command?

1237


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

1062


What are different types of shell?

929


What is the first line in a shell script?

1110


Explain about non-login shell files?

1214