#!/bin/bash # # Parity check # echo "Please enter a number: " read num if [ $num%2 -eq 0 ]; then echo "$num is even!" else echo "$num is odd!" fi
But if I change my if-statement to this:
if (( $num%2 == 0 ))
then it works nicely.
The point is that I get this error all the time. It doesn't matter whether it is if-statement or while-loop or similar things. I mean if I use the usual comparison keywords from bash and square brackets, it doesn't work. But if I use the other C based comparison signs, and parentheses it works nicely. Is it the problem that I don't use bash-like things correctly?