write a shell program to check wheather a given string is
pallindrome or not?
Answer Posted / goutamkumar
len=0
i=1
tag=0
echo -n "Enter a String: "
read str
len=`echo $str | wc -c`
len=`expr $len - 1`
halfLen=`expr $len / 2`
while [ $i -le $halfLen ]
do
c1=`echo $str|cut -c$i`
c2=`echo $str|cut -c$len`
if [ $c1 != $c2 ] ; then
i=$halfLen
tag=1
fi
i=`expr $i + 1`
len=`expr $len - 1`
done
if [ $tag -eq 0 ]
then
echo "String is Palindrome"
else
echo "String is not Palindrome"
fi
| Is This Answer Correct ? | 6 Yes | 1 No |
Post New Answer View All Answers
What are the 3 standard streams in linux?
How can the contents of a file inside jar be read without extracting in a shell script?
Why is a script important?
How will you copy a file from one machine to other?
Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.
Explain about "s" permission bit in a file?
What is web script?
c program to display the information of given file similar to givan by the unix or linux command ls -l
I have 2 files and I want to print the records which are common to both.
What is subshell?
Can you write a script to portray how set –x works?
What is .sh file in mac?
c program which behaves like a shell(command interpreter). it has its own prompt say "NewShell$".any normal shell command is executed from your shell by starting a child process to execute a system program corrosponding to the command
How to pass an argument to a script?
What exactly is a shell?