Shell if statement Parameters

Source: Internet
Author: User

◆ Parameter description
-B. returns true if the file exists and is a block file.
-C: returns true if the file exists and is a character file.
-D. If pathname exists and is a directory, true is returned.
-E: returns true if the file or directory specified by pathname exists.
-F returns true if the file exists and is a regular file
-G returns true if the file or directory specified by pathname exists and the sgid bit is set.
-H returns true if the file exists and is a symbolic link file. This option is invalid in some old systems.
-K. If a file or directory specified by pathname exists and a "Sticky" bit is set, the system returns the true value.
-P: returns true if the file exists and is a command pipeline.
-R: returns true if the file or directory specified by pathname exists and is readable.
-S: returns true if the file size is greater than 0.
-U returns true if a file or directory specified by pathname exists and SUID is set.
-W returns true if the file or directory specified by pathname exists and is executable. A directory must be executable for its content access.
-O returns true if a file or directory specified by pathname exists and the user specified by the valid user ID of the current process is owned by it.

◆ Single branch structure
Syntax:
If condition
Then command
Fi
Or
If condition; then Command
Fi
Tip: a semicolon is equivalent to a line feed. The above two syntaxes are equivalent.

◆ Dual Branch Structure
Syntax:
If condition
Then
Instruction Set
Else
Instruction Set
Fi

◆ Multi-branch structure
Syntax:
If condition
Then command
Elif Condition
Then command
Else
Command
Fi

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.