If judgment in Shell

Source: Internet
Author: User

Tag: String null

Integer comparison:

-EQ equals to, for example, if ["$ A"-EQ "$ B"]

-Ne is not equal to, for example, if ["$ A"-ne "$ B"]

-GT is greater than, for example, if ["$ A"-GT "$ B"]

-Ge is greater than or equal to, for example, if ["$ A"-ge "$ B"]

-Lt is less than, for example, if ["$ A"-lt "$ B"]

-Le is less than or equal to, for example, if ["$ A"-Le "$ B"]

<Less than (double parentheses are required), such as: ("$ A" <"$ B "))

<= Less than or equal to (double parentheses are required), for example: ("$ A" <= "$ B "))

> Greater than (double parentheses are required), such as: ("$ A"> "$ B "))

> = Equal to or greater than (double parentheses required), for example: ("$ A"> = "$ B "))

String comparison:

= Equals, for example, if ["$ A" = "$ B"]

= Equal to, such as: If ["$ A" = "$ B"]

! = Reverse, for example, if ["$ "! = "$ B"]

-Z string is "null". The length is 0.
-N string is not "null"

Other judgment parameters:

-E file exists
-File A exists (discarded)
-F determines that the file is a regular file (normal file, non-directory or device)
-S file length is not 0
-D: determines that the object is a directory.
-B determines that the object is a block device.
-C: determines that the object is a character device.
-P: the object to be determined is a pipeline.
-H indicates that the file is a symbolic connection.
-L identify the file as a symbolic connection
-S (uppercase) determines that the file is a socket
-T is the file descriptor associated with a terminal device. The stdin [-T0] or [-T1] used to detect scripts is a terminal.
-The R file has read permission for the user who runs the script
-W file has write permission for the user who runs the script
-The X file has the execution permission for the user who runs the script.
-U set-user-ID (SUID) indicates the file, that is, the root permission file that common users can use, implemented through chmod + S File
-K: Set the pasting position
-O the user who runs the script is the file owner.
The Group-ID of the-G file is the same as the user who runs the script.
-N: indicates whether the object has been modified since it was last read.

F1-nt F2 file F1 is newer than F2
Is F1-ot F2 earlier than F2?
Does F1-Ef F2 file F1 and F2 hard connect to the same file?



This article is from the "Linux" blog, please be sure to keep this source http://520and519.blog.51cto.com/2254416/1557667

If judgment in Shell

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.