Shell common file, string, two-tuple integer test operator-Continuous update

Source: Internet
Author: User
Tags logical operators


Frequently used file test operators-ongoing updates

- e -- exist

File exists is True

- F -- file

File exists and is true for normal files

- D -- Directory

File exists and is directory-True

-s--size

The file exists and the size is not zero for true

-r--read

File exists and can be read as true

-w--write

File exists and can be written as true

-x--executable

File exists and can be executed as true

-l--link

The file exists and is true for the linked file

F1-nt f2--new than

F1 than F2 new is true

F1-ot F2--old than

F1 is true compared to F2 old


Common string test operators-in continuous update


-N "String"
No zero if the length of the string is not 0, it is true
-Z "string" Zero if the string has a length of 0, it is true
"String 1" = "String 2"
True if string 1 equals string 2, "= =" can be used instead of
"String 1"! = "String 2" True if string 1 is not equal to string 2







Common two-dollar integer test operator-Continuous update


Use in [] and test
(())、[[]]
Description
-eq
=
equals, equal.
-ne
!=
Not equal to, no equal
-gt
>
Greater than, greater than
-ge
>= Greater than or equal, greater equal
-lt
<
Less than
-le
<=
Less than or equal equal

Note: When using "<" > "in [], you need to escape with" \ ", otherwise an error will occur.


logical operators

[] and test are used
[[]] and &&
Description
-A
&&
And, with, both sides are true, the result is true
-O
||
Or, or, one of the two sides is true, the result is true


Not, non, different on both sides, the result is true

This article is from the "12245798" blog, please be sure to keep this source http://12255798.blog.51cto.com/12245798/1902846

Shell common file, string, two-tuple integer test operator-Continuous update

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.