Shell (4)-test test, [], logic &&, || file -f, -d, -x, -eq, -gt, -ge, -lt, -le, -ne

(1) The usage of test
Insert picture description here
(2) []
Insert picture description here
(3) &&
Insert picture description here
Insert picture description here
can also be seen that the front is successful and then executed, the front is unsuccessful, and the later is not executed
(4) ||
Insert picture description here
or the idea
(5) -f, -d, -x
-f is used to determine whether the file exists:
Insert picture description here
-d is used to determine whether the file is a directory
-x is to determine whether the file is executable
(6) -eq, -gt, -ge, -lt, -le, -ne
are equal to, Greater than, greater than or equal to, less than, less than or equal to, not equal to

Guess you like

Origin blog.csdn.net/weixin_48445640/article/details/109183268