write a shell script to identify the given string is
palindrome or not?
Answer Posted / gaurav shah.ait
tput clear
echo -e "Enter String :- \c"
read str
len=`expr $str|wc -m `
len=`expr $len - 1`
len1=`expr $len `
echo -e "Reverse String :- \c"
while [ $len -ne 0 ]
do
s1=` expr $str|cut -c$len `
echo -e "$s1\c "
len=` expr $len - 1 `
done
len=`expr $str|wc -m `
len=`expr $len - 1`
echo ""
n=1
flag=0
while [ $len -ne 0 ]
do
fst=` expr $str|cut -c$n `
lst=` expr $str|cut -c$len `
len=` expr $len - 1 `
n=` expr $n + 1`
if test $fst != $lst
then
flag=1
fi
done
if test $flag = 1
then
echo "Given String Is Not Palindrome"
else
echo "Given String Is Palindrome"
fi
| Is This Answer Correct ? | 16 Yes | 9 No |
Post New Answer View All Answers
How will you find the 99th line of a file using only tail and head command?
Explain about the exit command?
Give some situations where typing error can destroy a program?
What language is bash?
Explain about echo command?
What are types of shells?
What is the significance of the shebang line in shell scripting?
Using set -A write a script to print the output of the ls command in 5 columns with two spaces between each column. Pretend that ls does not have multicolumn output.
What does $@ mean in shell?
Explain how you Automate your application using Shell scripting.
determine the output of the following command: echo ${new:-variable}
What is bash command used for?
What does .sh file contain?
What are the four fundamental components of every file system on linux?
What is bash shell command?