and the test command equivalent, the user Boolean judgment, such as:
1 a='abc'2if'abc' ] 3 Then 4 " Yes " 5 Else 6 " No " 7 Fi
Equivalent to
1 if ' ABC ' 2 Then 3 " Yes " 4 Else 5 " No " 6 Fi
When using [], be aware that:
1. [] left and right brackets to leave a space, or will error
2. If the value on the left side of = = is empty, it will cause the command to go wrong, in order to prevent this, usually add an extra string to the left or right, for example:
if [${a}x = = Abcx]
Also, note the difference between the parentheses and the double brackets:
Parentheses are used in arithmetic operators, which are similar to the Let command when used for assignment operations, and are referenced here
Let a=5((a=ten)) echo $a, $b
((a= $a +7)) # Add 7 to a((a = a + 7)) # Add 7 to a. Identical to the previous command. ((A + = 7)) # ADD 7 to a. Identical to the previous command. ((a = random% + 1)) # Choose A random number from 1 to ten. # is modulus, as in C.
Double parentheses to the left plus the $ symbol to replace the result, such as:
echo $ (a>)
A single () is used to execute the corresponding command in the new Subshell, such as:
(CD..) /.. /)
It is important to note that this command does not change the current directory after it has been executed
Resources:
Http://mywiki.wooledge.org/ArithmeticExpression
Http://stackoverflow.com/questions/2188199/how-to-use-double-or-single-bracket-parentheses-curly-braces
Shell Parenthesis Usage Introduction