Shell file expression

Source: Internet
Author: User

file Expression

-e filename true if filename exists
-d filename If filename is a directory, true
-F filename True if filename is a regular file
-L filename True if filename is a symbolic link

-r filename If filename is readable, true
-W filename if filename is writable, true
-x filename If filename is executable, true
-S filename true if the length of the file is not 0
-H filename True if the file is a soft link
Filename1-nt filename2 If filename1 is newer than filename2, it is true.
Filename1-ot filename2 If filename1 is older than filename2, it is true.

An integer variable expression
-eq equals
-ne Not equal to
-GT Greater than
-ge greater than or equal to
-lt less than
-le less than or equal to

string-Variable expression

if [$a = $b] true if string1 equals string2
string allows an equal sign with an assignment number
if [$string 1! = $string 2] True if string1 is not equal to string2
If [-n $string] returns 0 (true) if string is non-null (not 0)
If [-Z $string] True if string is empty
If [$sting] if string is not NULL, return 0 (and-n similar)

Logical Non! The opposite of the conditional expression

if [! expression]
if [!-D $num] If there is no directory $num

逻辑与 –a                   条件表达式的并列

If [expression 1–a-expression 2]

逻辑或 -o                   条件表达式的或

If [expression 1–o-expression 2]

Shell file expression

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.