Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Check If A Number Is Even Or Odd In Bash Shell Scripts

NUMBER=10

if [ $(($NUMBER%2)) -eq 0 ]
then
  echo "even"
else
  echo "odd"
fi

To check for just and odd number, use :

NUMBER=9

if [ $(($NUMBER%2)) -ne 0 ]
then
  echo "odd"
fi