1.Test File status
Table 1 File status test
-D directory-s file length is greater than 0, not empty -F: regular file -L symbolic connection -R readable-x executable |
-S file length is greater than 0, not empty -W writable -The U file has the s u I d bit setting. -X executable |
2.Use logical operators during testing
-Logic A and the operators are true on both sides, and the result is true. Otherwise, the result is false.
-O logic or, if either side of the operator is true, the result is true. Otherwise, the result is false.
Example:
[-R t.txt-a-W t.txt]
Echo $?
0
3.String Testing
= Two strings are equal.
! = Two strings.
-Z empty string.
-N is a non-empty string.
Example:
Test-Z $ path
Echo $?
1
4.Test Value
-The EQ value is equal.
-The ne values are not equal.
-The first number of GT is greater than the second number.
-Lt: the first number is smaller than the second number.
-The first number of Le is less than or equal to the second number.
-The first number of Ge is greater than or equal to the second number.
Example:
[80-lt 100]
Echo $?
0
5. exprUsage:
Expr 10/* 10
100
Extpr 10/10
1