Shell script to check a given string is palindrome or not, Programming Languages

W.A.S.S to check whether a given string is palindrome or not.

 

Program

 

# W.A.S.S to check whether a given string is palindrome or not.

#07MCG20

 

echo "Enter any string"

read str

len=`echo $str | wc -c`

len=`expr $len - 1`

result=""

while test $len -gt 0

do

temp=`echo $str | cut -c $len`

len=`expr $len - 1`

result=`echo $result$temp`

done

echo "$result"

if test "$result" = "$str"

then

echo "Given string is palimdrom"

else

echo "Given string is not palimdrom"

fi

 

Output

 

Enter any string

madam

madam

Given string is palimdrome

 

Enter any string

mca

acm

            Given string is not palimdrome

Posted Date: 9/26/2012 6:27:41 AM | Location : United States







Related Discussions:- Shell script to check a given string is palindrome or not, Assignment Help, Ask Question on Shell script to check a given string is palindrome or not, Get Answer, Expert's Help, Shell script to check a given string is palindrome or not Discussions

Write discussion on Shell script to check a given string is palindrome or not
Your posts are moderated
Related Questions
Write a script that will list and count all of the images in a given HTML web page. Each image starts with

a) Write a program i_language(Sentence,NewSentence) that translates a sentence to the i-language. In this language all vowels are changed to i and all other characters are kep

VARIATION OF PARAMETERS - HIGHER ORDER DIFFERENTIAL EQUATIONS We now require taking a look at the second method of finding a particular solution to a differential equation

Tamagochi were all the rage in the 90's as a small toy that had limited functionality but modelled a pet. The "owner" could do the following • Feed the pet • Heal the pet

You are asked to develop a replicator (client) that distributes a large job over a number of computers (a server group) on a single switched LAN (our BU04 lab). In this assignment,

Question 1 How will you add styles to a document? Question2 How will you view XML in different ways? Question 3 Explain various file handling mechanism available in PERL

A psychologist is interested in learning about the voting behavior of college students.  (4 points for each part.)Design a study which would yield data on this topic. a. state y

1. Write a program that reads a minimum of three command line arguments and displays the program's results. a. Command Line arguments:  i. The first argument will be the program

Lennie McPherson, proprietor of Lennie''s Bail Bonds, needs to calculate the amount due for setting the bail. Lennie requires something of value as collateral, and his fee is 10%

Carnivorous Carla only eats pizza if it has at least three of the following ingredients: ham, pepperoni, salami, italian sausage, bacon. You have the function contains() to check w