Shell logical operators, logical expressions

Source: Internet
Author: User
Tags logical operators

Logical symbols

1. about the file and directory of the detection of Logical volume label!

- F Common! Detect if "Archive" exists eg:if [-f filename]

- D common! Detects if the directory exists

- B detection is a "block file"

- C detection is a "character file"

- s detection is a "socket tag file"

- L detection is a "symbolic Link's profile"

- E detects if "something" exists!

2. about the program's Logical volume label!

- g detection is owned by the program performed by the GID

- o detection is owned by the program executed by the UID

- P detects if a name pipe or FIFO is being transmitted between programs (to be honest, this is not a good idea!) )

3. about the property of the file detection!

- R to detect if a property is readable

- w detection is a property that can be written

- x detect whether the property is executable

- s detection is a "non-blank file"

- U detect if a property with "SUID"

- g detection for properties with "SGID"

- K detect if there is a property of "sticky bit"

4. judgment and comparison between two files; for example [Test file1-nt file2]

-nt The first file is newer than the second one.

-ot The first file is older than the second one.

-ef The first file is the same file as the second file (link and other files)

5. logical "and" "or (OR)"

The meaning of && logic

|| The meaning of a logical OR

Operation symbols

= equals applies To: integer or string comparison if in [], only the string

! = is not equal to: integer or string comparison if in [], only the string

< less than applied: integer comparison in [], cannot use the representation string

> greater than applied: integer comparison in [], cannot use the representation string

-eq equals applies To: integer comparison

-ne Not equal to: integer comparison

-lt less than applied to: integer comparison

-GT greater than applied: integer comparison

-le less than or equal to: integer comparison

-ge greater than or equal to: integer comparison

- A both are established (and) logical Expressions –a logical expressions

- o unilateral formation (or) logical expression –o logical expression

- Z empty string

- N non-empty string


This article is from the "Linux_woniu" blog, make sure to keep this source http://llu1314.blog.51cto.com/5925801/1965332

Shell logical operators, logical expressions

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.