Conditional Judgment of shell scripts

Source: Internet
Author: User

Scripting: Stacking of commands

The first line of any script:

#!/bin/bash: The Interpreter path

In addition to the previous # number as a comment

Execute permission before script execution: chmod +x file name


Condition Judgment in bash:

Condition Test Type:

Integer test

Character test

File test


Conditional test expression:

[Expression]

[[Expression]]

Test expression


Integer comparison:

-EQ: Tests whether two integers are equal: For example, $a-eq $b, return 0 as equals

-ne: Test for two integers: unequal to true, equal to False

-GT: Test whether a number is greater than one number: greater than true, not quite false

-LT: Test whether a number is less than one number: less than true, not small for false

-ge: greater than or equal to

-le: Less than or equal to


if judgment condition; then

Statemtent1

.

.

Fi



Conditional Judgment of shell scripts

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.