4 ms·
> How many square brackets do I need? 1 or 2? 2 > Do I use == or -eq? For string comparison, use '='. For arithmetic comparison, use -eq, -gt, -lt, etc. > W
by chriswarbo 4y ago
> How many square brackets do I need? 1 or 2?
2
> Do I use == or -eq?
For string comparison, use '='. For arithmetic comparison, use -eq, -gt, -lt, etc.
> Where does the semicolon go again?
Whenever you're putting multiple lines on one. If you use multiple lines, you don't need semicolons.
For example:
if [[ "$result" = 'SUCCESS' ]] && [[ "$count" -gt 0 ]]
then
echo 'Hooray!'
fi
- mcluck 4y agoPeople complain about === in JS but at least I can just use it everywhere and stop using ==. Needing to remember which equality check to use based on type is so frustrating