echo -e "Enter a string: \c" read str len=`expr length $str` rev="" while [ $len -gt 0 ] do r=`echo $str | cut -c $len` rev=`echo $rev$r` len=`expr $len - 1` done echo Reverse of $str is $rev if [ $str = $rev ] then echo Palindrome else echo Not palindrome fi
No comments:
Post a Comment