Conditional judgment in Shell

Source: Internet
Author: User
Tags sorts

If

In the

-Z

To

-D

The meaning

2011-09-05 10:30

[-A FILE]

If

FILE

The existence is true.

[-B FILE]

If

FILE

Exists and is a block special file is true.

[-C FILE]

If

FILE

exists and is a word special file is true.

[-D FILE]

If

FILE

exists and is a directory is true.

[-E FILE]

If

FILE

The existence is true.

[-F FILE]

If

FILE

exists and is an ordinary file is true.

[-G FILE]

If

FILE

exists and has been set

SGID

Is true.

[-H FILE]

If

FILE

Is true if it exists and is a symbolic connection.

[-K FILE]

If

FILE

exists and the sticky bit has been set is true.

[-P FILE]

If

FILE

exists and is a name pipe

(F

If

O)

Is true.

[-R FILE]

If

FILE

Is true if it exists and is readable.

[-S FILE]

If

FILE

exists and is not of the size

0

Is true.

[-T FD]

If the file descriptor

Fd

Open and point to a terminal is true.

[-U FILE]

If

FILE

exists and sets the

SUID (set user ID)

Is true.

[-W FILE]

If

FILE

If

FILE

Is true if it exists and is writable.

[-X FILE]

If

FILE

Is true if it exists and is executable.

[-O FILE]

If

FILE

exists and is a valid user

Id

Is true.

[-G FILE]

If

FILE

exists and is valid user group is true.

[-L FILE]

If

FILE

Is true if it exists and is a symbolic connection.

[-N FILE]

If

FILE

Exist

and has been mod

If

IED since it was last read

Is true.

[-S FILE]

If

FILE

exists and is a socket is true.

[File1-nt FILE2]

If

FILE1 have been changed more recently than FILE2,

Or

If

FILE1 exists and FILE2 does not

Is true.

[File1-ot FILE2]

If

FILE1

Than

FILE2

to old

,

Or

FILE2

exists and

FILE1

Is true if it does not exist.

[File1-ef FILE2]

If

FILE1

And

FILE2

Pointing to the same device and node number is true.

[-O optionname]

If

Shell

Options

"Optionname"

It is true to turn on.

[ -

Z string] "string"

is true if the length is zero.

[ -

n string] or [string] "string"

is non-zero in length

Non-zero

Is true.

[STRING1 = = STRING2]

If

2

The same string.

"=" may be used instead of

"= =" for strict POSIX compliance

Is true.

[STRING1! = STRING2]

True if the strings are not equal.

[STRING1 < STRING2]

If

"STRING1" sorts before "STRING2"

Lexicographically in the current locale

Is true.

[STRING1 > STRING2]

If

"STRING1" sorts after "STRING2"

Lexicographically in the current locale

Is true.

[ARG1 OP ARG2] "OP" is one of

-eq,-ne,-lt,-le,-gt Or-ge. These arithmetic

Binary operators return True if "ARG1" is equal to, not equal to, less than, less

than or equal to, greater than

, or greater than or equal to "ARG2", respectively.

"ARG1" and "ARG2" are integers.

Conditional 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.