Harry Omvlee · @harryomvlee
6 followers · 42 posts · Server mastodon.nl

Help, , , ,

Determine whether the date number is even or odd to execute or not a given command.

a=$(date +%d)
b=2
if ! (( $a % $b ))
then
echo "Today's date has an even number."
else
echo "Today's date has an odd number."
fi

Something is wrong here: the exclamation mark creates a negation, which shouldn't. By the way, the result is fine.

Where is my mistake? What am I actually not doing right here?

#syntax #dedivisions #bashscripting #bash

Last updated 2 years ago