This is the traditional shell test command. It is available on all POSIX shells. The test command sets an exit code and the if statement acts accordingly. Typical tests are whether a file exists or one number is equal to another.
This is a new upgraded variation on test that bash supports. This test command also sets an exit code and the if statement acts accordingly. Among its extended features, it can test whether a string matches a regular expression.
This performs arithmetic. As the result of the arithmetic, an exit code is set and the if statement acts accordingly. It returns an exit code of zero (true) if the result of the arithmetic calculation is nonzero. Like [[…]], this form is not POSIX and therefore not portable.
This runs command in a subshell. When command completes, it sets an exit code and the if statement acts accordingly.
A typical reason for using a subshell like this is to limit side-effects of command if command required variable assignments or other changes to the shell’s environment. Such changes do not remain after the subshell completes.
command is executed and the if statement acts according to its exit code.
actually [ is a built in, as is test. There are binary versions available for compatibility reasons. Check out help [ and help test.
$ my_var = 4 my_var: command not found
because Bash interprets the above line as: execute the my_var command with arguments = and 4. But the my_var command doesn’t exist so we get an error. The proper way to do the assignment is:
$ my_var=4
https://unix.stackexchange.com/questions/306111/confused-about-operators-vs-vs-vs
https://uvesway.wordpress.com/2013/03/11/some-whitespace-pitfalls-in-bash-programming/