[] and [[]] can determine whether the variable is empty, [ $a] [[$a]] [ ! $a] [[! $a]] No difference
In Linux, we can use the test command to determine if a string is empty, and the test command gives us the "-Z option" and the "-N option," which you can use to determine if the string is empty.
The "-Z option" Determines whether the specified string is empty, returns true if it is empty, returns false if not NULL, and z can be interpreted as zero
The "-N option" Determines whether the specified string is empty, returns true if it is not empty, returns False if NULL, and-n can be understood as Nozero
when you use the options "-N" or "-Z" in test to determine if a variable is empty, you must enclose the variable with double quotation marks on the outside side. the [] is the same as the tets effect, while [[]] does not use double quotes on the variable.
When you use the Test-n command to determine if the value of variable B is empty, you should return false, because the-n option of the test command indicates that the specified string is non-empty, returns True when NULL, returns FALSE, but the return value of the command "Test-n $b" in the example above is true (should be false), which is obviously incorrect
When you use "[[]]", you cannot use "-a" or "-o" to connect multiple conditions.
When using "[]", If you use "-a" or "-o" to connect multiple conditions, "-a" or "-o" must be included within "[]".
When using "[]", If you use "&&" or "| |" Connect to multiple criteria, "&&" or "| | |" Must be outside the "[]".
Shell [] differs from [[]]