Test operation symbols in shell scripts and && | |

Source: Internet
Author: User

测试操作符 based on the modified time of the file
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

&& 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 && | |

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.