测试操作符
Common Test Operators |
English name |
Description |
-F file |
file |
files exist and are normal files True, that is, test expressions are set |
-d file |
Direct Ory |
file exists and is true for the catalog file, that is, the test expression is |
-S file |
size |
file exists and the file size is not 0 true, that is, the test expression is established |
-e file |
exist |
file exists as true, that is, the test expression is set |
-r file |
read |
the file exists and is readable as true, that is, the test expression is set |
-W file |
write |
file exists and can be written as true, that is, the test expression is established |
-X file |
executable |
file exists and is executable as true, that is, the test expression is set |
-L file |
link |
file exists and is true for linked file, that is, test expression established |
fi-nt F2 |
newer than |
file F1 is newer than file F2 is true, that is, the test expression is established. Based on the modified time of the file |
f1-ot F2 |
older than |
file F1 than file F2 old is true, that is, the test expression is established. Calculation of |
&& with |
operator |
based on the modified time of the file
&& operators
Format: Command1 && Command2
&& the command on the Left (command 1) returns True (that is, returns 0, executed successfully) and the command (Command 2) on the right side of the,&& can be executed, in other words,"If this command succeeds && executes this command."
|| Operator
Format: Command1 | | Command2
|| is the opposite of &&. if | | The command on the left (Command1) did not execute successfully, then execute | | The command on the right (Command2), or in other words,"If this command fails to execute | | Then execute this command. "
Test operation symbols in shell scripts and && | |