To check whether a number is palindrome or not, we have to reverse the number, and then if the actual number and the reversed number are same, then this is palindrome. In Bash, performing the reverse operation is very easy. We have to use the ‘rev’ command to do that. Let us see the program to understand clearly.
#!/bin/bash # GNU bash Script n=12321 rev=$(echo $n | rev) if [ $n -eq $rev ]; then echo "Number is palindrome" else echo "Number is not palindrome" fi
Number is palindrome