BASH:check if a number is even or odd


In a bash script you might need to check if a var is even or odd , 

in my case im going to use a if to make that check

You can use this simple code to make that check and display the result.

the result will be : 

5 thoughts on “BASH:check if a number is even or odd

  1. Tested on Mac and Linux. None of them worked. The syntax is totally wrong. Why does this result appear on the top of google search???

  2. CC – The same thing happened to me when I cut-n-pasted the code. When I deleted the leading spaces on every line, it worked fine.

Leave a Comment

Your email address will not be published. Required fields are marked *