Linux if command judgment condition summary, linuxif

Source: Internet
Author: User

Linux if command judgment condition summary, linuxif

Linux if command judgment condition Summary
Linux if command

Limit type of file attributes

-A: If the file exists

-B. If the file exists and the file is a regional Device File

-C: returns true if the file exists and is a character device 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 common 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 the file or directory specified by pathname exists and the "sticky" bit is set, the system returns true.

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

-T file descriptor if the file descriptor is enabled and linked to a terminal

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

-X if the file exists and the file has executable Properties

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

-G if the file exists and the file is owned by a valid group id

-L if the file exists and the file is a symbolic link file

-S if the file exists and the file is a Socket File

-N if the file exists and the file has been modified since the last read

File 1-nt file 2 if file 1 is newer than file 2, or file 1 exists, file 2 does not exist

File 1-ot file 2 if file 1 is older than file 2, or file 1 does not exist, file 2 exists

File 1-ef file 2 if file 1 and file 2 reference the same device and inode number

String-Based Conditional Criterion

-Z empty string (if the string length is 0)

-N non-empty string (if the string length is not 0)

If the length of a string is not 0

! = If the two strings are not equal

= If the two strings are equal

= If the two strings are equal

String 1 <string 2 if string 1 is smaller than string 2

String 1> string 2 if string 1 is greater than string 2


Conditional judgment of formula

-Eq equals

-Ne is not equal

-Gt greater

-Lt is less

-Le is less than or equal

-Ge is greater than or equal

Condition Determination of Bash options

-O set Option name if the option is enabled

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.