In Bash scripts both single
[ and double brackets
[[ can used for conditionals.
Only single brackets are POSIX compliant, however most modern shells support double brackets as well.
The biggest benefit of using double brackets is that doesn't split variables, so we don't have to wrap them in quotes.
# Single brackets: Need to wrap variable in quotes [ -e "$FILE" ] # Double brackets [[ -e $FILE ]]
In general it's considered safer and less error-prone to use double brackets. For me it will be the default.
man test in the shell to open the manual for