write a shell script to identify the given string is
palindrome or not?

Answer Posted / akshay telang

#! /usr/bin/ksh
string=$1
str1=$1
pal=""
typeset -R1 last

while ((${#string})) ; do
last=$string
pal=${pal}${last}
if ((${#string} > 1)) ; then
typeset -L$((${#string}-1)) oneLess=$string
string=$oneLess
else
string=
fi
done
if [ "$str1" == "$pal" ]
then
echo "String is a Palindrome"
else
echo "String is not a Palindrome"
fi

Is This Answer Correct ?    24 Yes 28 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In my bash shell I want my prompt to be of format '$"present working directory":"hostname"> and load a file containing a list of user-defined functions as soon as I log in, how will you automate this?

719


What is bash coding?

578


Given a file find the count of lines containing the word "abc".

1120


What is a batch file used for?

649


How can the contents of a file inside jar be read without extracting in a shell script?

701






Is shell and terminal the same?

682


Differentiate between ‘ and ” quotes.

685


What is sudo command?

629


How to redirect both standard output and standard error to the same location?

748


What language is bash written in?

644


What language is used in terminal?

638


Is shell scripting useful?

660


What are the different commands available to check the disk usage?

566


What is the syntax of "nested if statement" in shell scripting?

706


What can scripts do?

733