GTU OS Program - 10
10. Write a shell script to check entered string is palindrome or not.
Complete code
echo "Enter the string to check: " read str 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"
Interpreting the palindrome.sh file and executing it in terminal
tkanu025@hp:~/lab_solutions$ chmod +x palindrome.sh tkanu025@hp:~/lab_solutions$ ./palindrome.sh
Output
Comments