Test structure:
The test command can be used to test the true and false of the expression condition, and returns0,false, which is not 0;
format:
Test expression
#expression是一个表达式, the expression can be compared by numbers, strings, text and file attributes, and can be added to various arithmetic, string, text operators, etc.;
[Expression]
#其中 "[" is the command to start the test, but requires a "]" to be paired with it after expression, paying special attention to the spaces before "[" and "]" are necessary.
The #该方式经常与if, case and while statements are used as the judging conditions of the process control statements;
A comparison between integers:
comparators: eq, GT, Lt//equal, greater than, less than
Test "NUM1"-eq "num2"
["Num1"-eq "num2"]
The comparer cannot be used for comparisons between floating-point numbers, remember
A comparison between strings:
String to test whether string is not NULL,
-N string to test whether the string is not empty
-Z String to test if string is empty
Operators for file operations:
Judging usage in the shell