Judgment parameters in [] (brackets) in Linux

Source: Internet
Author: User

Source: http://www.diybl.com/course/6_system/linux/Linuxjs/20081117/151774.html

For more information, see the original article.

 

-B file: if the file exists and is a special block file, it is true.
-C file: if the file exists and is a special character file, it is true.
-D file: if the file exists and is a directory, it is true.
-E file: true if the file exists
-F file: if the file exists and is a rule file, it is true.
-G file: if the file exists and the value of SGID is set, it is true.
-H file: true if the file exists and is a compliant Link
-K file: if the file exists and the "Sticky" bit value is set
-P file: if the file exists and is a named pipe, it is true.
-R file: true if the file exists and is readable
-S file: true if the file exists and its size is greater than zero
-U file: true if the file exists and the SUID bit is set
-W file: true if the file exists and can be written
-X file: true if the file exists and is executable
-O file: true if the file exists and is owned by a valid user ID
-Z string if the string length is 0, it is true
-N string: true if the string length is not 0
String1 = string2 if the two strings are equal, it is true.
String1! = String2: true if two strings are not equal
Int1-EQ int2 if int1 is equal to int2, true
Int1-ne int2: true if int1 is not equal to int2
Int1-lt int2 if int1 is smaller than int2, true
Int1-Le int2 if int1 is smaller than or equal to int2, true
Int1-GT int2 if int1 is greater than int2, true
Int1-ge int2 if int1 is greater than or equal to int2, true
! If expr is false, the composite expression is true. Expr can be any valid test expression
Expr1-A expr2 if both expr1 and expr2 are true, the entire formula is true.
Expr1-O expr2 if either expr1 or expr2 is true, the entire formula is true.

 

Source: http://www.cppblog.com/prayer/archive/2008/08/12/58662.html

For more information, see the original article.

-R file | returns true if file is a readable file.
-W file | returns true if the file is a writable file.
-X file | returns true if file is an executable file.
-E file | returns true if the file exists.
-O file | returns true if the file owner is the current user.
-Z file | returns true if the file length is 0.
-F file | returns true if file is a normal file.
-D file | returns true if file is a directory.

-D file | returns true if file is a directory.
-F file | returns true if file is a normal file.
-R file | returns true if the file is an engraved file.
-S file | returns true if the file length is greater than 0.
-W file | returns true if the file is a writable file.
-X file | returns true if file is an executable file.
-N str | returns true if the STR length is greater than 0.
-Z str | returns true if the STR length is 0.
If [-l Directory] determines whether link exists

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.