I found the existing answers confusing.
Personally, I just want to have something which looks and works like C.
This snippet works many times a day in production:
snapshotEvents=true
if ($snapshotEvents)
then
# Do stuff if true
fi
Andand to keep everyone happy, I tested:
snapshotEvents=false
if !($snapshotEvents)
then
# Do stuff if false
fi
Which also worked fine.
The $snapshotEvents
evaluates the contents of value of the variable. So you need the $
.
You don't really need the parentheses, I just find them helpful.
Tested on: GNU Bash, version 4.1.11(2)-release
Bash Guide for Beginners, Machtelt Garrels, v1.11, 2008