Frequently used file test operators-ongoing updates
- e -- exist |
File exists is True |
- F -- file |
File exists and is true for normal files |
- D -- Directory |
File exists and is directory-True |
-s--size |
The file exists and the size is not zero for true |
-r--read |
File exists and can be read as true |
-w--write |
File exists and can be written as true |
-x--executable |
File exists and can be executed as true |
-l--link |
The file exists and is true for the linked file |
F1-nt f2--new than |
F1 than F2 new is true |
F1-ot F2--old than |
F1 is true compared to F2 old |
Common string test operators-in continuous update
-N "String"
|
No zero if the length of the string is not 0, it is true
|
-Z "string" |
Zero if the string has a length of 0, it is true |
"String 1" = "String 2"
|
True if string 1 equals string 2, "= =" can be used instead of
|
"String 1"! = "String 2" |
True if string 1 is not equal to string 2
|
|
|
|
|
|
|
Common two-dollar integer test operator-Continuous update |
|
Use in [] and test
|
(())、[[]]
|
Description
|
-eq
|
=
|
equals, equal.
|
-ne
|
!=
|
Not equal to, no equal
|
-gt
|
>
|
Greater than, greater than
|
-ge
|
>= |
Greater than or equal, greater equal
|
-lt
|
<
|
Less than
|
-le
|
<=
|
Less than or equal equal
|
Note: When using "<" > "in [], you need to escape with" \ ", otherwise an error will occur.
logical operators |
[] and test are used
|
[[]] and &&
|
Description
|
-A
|
&&
|
And, with, both sides are true, the result is true
|
-O
|
||
|
Or, or, one of the two sides is true, the result is true
|
!
|
!
|
Not, non, different on both sides, the result is true
|
This article is from the "12245798" blog, please be sure to keep this source http://12255798.blog.51cto.com/12245798/1902846
Shell common file, string, two-tuple integer test operator-Continuous update