How to use the Linux shell if condition statement

Source: Internet
Author: User

Shell if

-B Returns True when file exists and is a block file
-C Returns True when file exists and is a character
-D returns True when pathname exists and is a directory
-E Returns True when a file or directory specified by pathname is present
-F Returns True when file exists and is regular
-G returns True when the file or directory specified by pathname is present and the Sgid bit is set
-H Returns True when file exists and is a symbolic link file, this option is not valid on some old systems
-K returns True when a file or directory specified by pathname exists and the "sticky" bit is set
-P Returns True when file exists and is a command pipeline
-R Returns True when the file or directory specified by pathname is present and readable
-s when file size is larger than 0 o'clock returns true
-U returns True when the file or directory specified by pathname is present and the SUID bit is set
-W Returns True when the file or directory specified by pathname exists and is executable. A directory must be executable for its content to be accessed.
-O Returns True when the file or directory specified by pathname is present and is owned by the user specified by the active user ID of the current process.

Compare character notation:
-eq equals
-ne Not equal to
-GT Greater than
-lt less than
-le less than or equal to
-ge greater than or equal to
-Z Empty string
* = Two characters equal
*! = Two characters Range
*-N Non-empty string

How to use the Linux shell if condition statement

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.