Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Write a shell program to check whether a given string is palindrome or not.

Posted By: Adriane Miller     Category: Unix / Linux / Ubuntu     Views: 35212

Write a shell program to check whether a given string
is palindrome or not.

Code for Write a shell program to check whether a given string is palindrome or not. in Unix / Linux / Ubuntu

clear
echo "Enter a string to be entered:"
read str
echo
len=`echo $str | wc -c`
len=`expr $len - 1`
i=1
j=`expr $len / 2`
while test $i -le $j
do
k=`echo $str | cut -c $i`
l=`echo $str | cut -c $len`
if test $k != $l
then
echo "String is not palindrome"
exit
fi
i=`expr $i + 1`
len=`expr $len - 1`
done
echo "String is palindrome"
  
Share: 



Adriane Miller
Adriane Miller author of Write a shell program to check whether a given string is palindrome or not. is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!