How can I write a shell predicate function event that takes an integer argument and tests if it's even or not?
Actually bash has a bitwise AND operator, so a bitwise AND with 1 is the same conceptually with useing
% 2 to get a remainder mod 2
[ $((var & 1)) -ne 0 ] && echo "odd" [ $((var & 1)) -eq 0 ] && echo "even"
(and save microseconds by skipping a division)
EDIT: removed expression with
! that somehow was history and a logical not