Common condition tests for bash in Linux commands: integer test eq, file Test-E, string test = =

Source: Internet
Author: User

Test method: Expression: expressed, expressed

[Expression]

[[Expression]]

Test expression

There are three common conditions tested in bash:

1. Integer test:

-eq equals

-lt less than

-ne Not equal to

-GT Greater than

-le less than or equal to

-ge greater than or equal to

Integer: Integers

integer1=63 integer2=77

[$INTEGER 1-eq $INTEGER 2]

[[$INTEGER 1-eq $INTEGER 2]]

Test $INTEGER 1-eq $INTEGER 2


2. File test:

-e file: Test files exist

-F File: Test files are normal files

-D File: Tests whether the specified path is a directory

-R File: Tests whether the current user has Read permission to the specified file

  - W File: Tests whether the current user has write access to the specified file

-X file: Tests whether the current user has execute permission on the specified file

[-E File] tests for the existence of file files

[[-E file]] tests for the existence of file files

Test the script for syntax errors:

Bash-n Script

Bash-x script: Stepping through a script

3. String Test:

This article is from the "Learn Linux history" blog, please be sure to keep this source http://woyaoxuelinux.blog.51cto.com/5663865/1863899

Common condition tests for bash in Linux commands: integer test eq, file Test-E, string test = =

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.