Shell command--if

Source: Internet
Author: User

The IF in [] is actually called a quick method of test. Bash's numeric and string comparison operators:

Note = spaces on both sides
String Numerical is true, if
x = y X-eq y
X! = y X-ne y
X < y X-lt y
X <= y X-le y
X > Y X-gt y
X >= y X-ge y
-N X X is not empty
-Z X X is empty

File attribute judgment

-D File:file exists and is directory (DICT)

-e File:file exists(xist)

-F File:file exists and is normal file (File)

-R file: User has file Read permission (Read)

-S file:file exists and is not empty (?)

-W File: User has Write permission to file (write)

File1-nt file2:file1 file2 New (new tHan)

File1-ot file2:file1 older than file2 (old Than)

Shell command--if

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.