Shell Command expr and test command, shellexprtest
You can use the expr command to perform operations such as +,-, *, \, and %. However, when using multiplication, add a \ symbol before.
You can use the test command to perform a logic test. There are four testing cases:
1. Integer Test
A. Determine whether two integers are equal -- test int1-eq int2
B. Determine whether two integers are unequal -- test int1-ne int2
C. Determine whether integer 1 is greater than integer 2 -- test int1-gt int2
D. judge whether integer 1 is greater than or equal to integer 2 -- test int1-ge int2
E. Determine whether integer 1 is smaller than integer 2 -- test int1-lt int2
D. judge whether integer 1 is less than or equal to integer 2 -- test int2-le int2
2. String Testing
A. judge whether the string is null. If it is null, return true. If it is not null, return false: test-z string.
B. judge whether the string is not null. If it is not null, the return result is true. If it is null, the return result is false: test-n string.
C. Determine whether the two strings are equal: test str1 = str2
D. Determine whether the two strings are not equal: test str1! = Str2
3. File Test
A. Determine whether the user has the permission to read the file: test-r filename
B. Determine whether the user has the write permission for the file: test-w filename
C. Determine whether the user has the executable permission for the file: test-x filename
D. Determine whether the file is a normal file: test-f filename
E. Determine whether the file is a directory: test-d filename
F. Determine whether the file is capitalized and not zero: test-s filename
G. Determine whether the device is a block Device File: test-B filename.
4. logical operations
A. True if both expressions are true at the same time; otherwise false: test expression 1-a expression 2
B. either of the two expressions is true, and both are false: test expression 1-o expression 2