The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

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

TODO: Pull subtitle into page object
Code
NUMBER=10

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

To check for just and odd number, use:

Code
NUMBER=9

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


Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

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


-- code
-- shell

NUMBER=10

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

-- p

To check for just and odd number, use:


-- code
-- shell

NUMBER=9

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




-- blurb

-- categories
-- Command Line
-- bash

-- metadata
-- date: 2023-05-17 18:15:27
-- id: 2pwitoms
-- site: aws
-- type: post
-- status: published