Determine parameters in the IF statement of Linux

Source: Internet
Author: User

Bash test file test:

-F: Test whether it is a normal file, that is, ls–l file type---D: Test whether it is a directory file, that is, file type D when ls-l; e: The test file exists, the existence is true, otherwise false;-r: The test file is readable for the current user;-W: The test file is writable for the current user;-x: The test file is executable to the current user;-S: Test file size is not empty, not empty is true, empty is false;-C: Test whether the file is a character file

Bash condition test:

Integer test:

Greater than:-gt less than:-lt equals:-eq greater than equals:-ge less than equals:-le not equal to:-ne

Character test:

>: Greater than <: less than = =: equals =~: Determines whether the left-hand string can be matched by the right pattern, usually used for [[]];[[$opt 1 =~ $opt 2]] generally do the beginning of the line, the end of the anchor; do not add quotation marks; Monocular:-Z $STRING: Empty is true, not empty is false ;-N $STRING: Empty is false, not empty is true;

Short-circuit operation: As long as the first half of the paragraph can determine the final result, the second half of the operation is no longer; and operation: true && true =  true && false =  false false && {true | false} = FALSE or arithmetic: false | | False = False False | | true = True | |   = True

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.