Match string

Replace true or false above with an expression.

Text check

x='abc'

if [[ "$x" == 'abc' ]]; then
  echo 'Yes!'
fi
# Yes!

Check numeric condition

AGE=20

if [[ "$AGE" -ge 18 ]]; then
  echo 'Major!'
fi
# Major!

Check maths condition

Use double brackets $((CALC)) to evaluate a mathematical expression.

[[ "$(($a))" -eq "$(($b))" ]]

OR

[[ "$((a == b))" -ne 0 ]]