1234567891011121314151617181920212223242526272829 |
- #!/bin/bash
- echo "Enter the string"
- read string
- len=`echo $string | wc -c`
- len=`expr $len - 1`
- flag=0
- v=`expr $len / 2`
- v=`expr $v + 1`
- for((i=1,j=$len;i < v ;i++,j--))
- {
- l=`echo $string |cut -c $i`
- k=`echo $string |cut -c $j`
- if [ $l == $k ]
- then
- flag=0
- else
- flag=1
- break
- fi
- }
- if [ $flag == 1 ]
- then
- echo "string is not pallindrome"
- else
- echo "string is palindrome"
- fi
|