Linux-shell test, linux-shell

Source: Internet
Author: User

Linux-shell test, linux-shell

Nature of testing:

Is an operation command

According to $? Return Value to determine whether the condition is true


Operation Specifications:

Format 1: test Condition expression

Format 2: [conditional expressions]


Contact Method for test operation:

Direct root & echo YES judgment result

Usage: [conditional expression] & echo YES


Test example:

[-D "/etc/fstab"] & echo YES

[-D "/boot/fstab"] & echo YES

[-F "/etc/fstab"] & echo YES

[-F "/boot"] & echo YES

Existence and identification:

-E: whether the target exists

-D: whether it is a directory

-F: whether it is a file


Permission Detection:

-R: whether the read permission exists.

-W: whether write permission exists

-X indicates whether the execution permission is exclusive.


Integer comparison:

-Equal = (equal)

-Ne is not equal to (not equal)

-Gt greater than (greater)

-Lt is less than (lesser)

-Ge is greater than or equal to (greater or equal)

-Le is less than or equal to (lesser or equal)


Integer comparison:

[$ (Who | wc-l)-eq 2] & echo YES


[$ USER = "root"] & echo YES

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.