[
is the same as the test
builtin, and works like the test
binary (man test)
[
in all the other sh-based shells in many UNIX-like environments&&
and ||
operators must be in separate brackets. !
outside the first bracket to use the shell's facility for inverting command return values.==
and !=
are literal string comparisons[[
is a bash
==
and !=
apply bash pattern matching rules, see "Pattern Matching" in man bash
=~
regex match operator!
, &&
, and ||
logical operators within the brackets to combine subexpressionsAside from that, they're pretty similar -- most individual tests work identically between them, things only get interesting when you need to combine different tests with logical AND/OR/NOT operations.