Shell Script 2

Source: Internet
Author: User
I. Condition TEST ACTION

The shell environment determines whether the execution succeeds based on the return status value ($?) after the command executes, or if the return value is 0 o'clock, which indicates a success or failure or exception. You can test specific conditions by using a specialized test tool---the test command.
(1) file test
A file test refers to a file or directory according to the specified path name, or whether the file is readable, writable, executable, etc.
(2) Integer value comparison: The integer value comparison refers to the relationship between the first number and the second number according to the given two integer values, such as whether it is greater than, equal to, less than the second number.
(3) string comparison: string comparison is usually used to check the user input, the system environment, such as whether the conditions are met, in the shelluanjing to provide interactive operation, l environment, can also be used to determine whether the user's location parameters meet the requirements.
(4) Logic test for multiple conditions: logical testing refers to the determination of dependencies between two or more conditions

Ii. using the IF statement: in a shell script application, the If statement is the most commonly used process control method, which is used to perform different operations with the specific condition test results.

(1) Single Branch if statement: For a light-pink-live selection structure, the corresponding code will be executed only when the condition is set, otherwise no action is taken.
The ① Condition Test Action Statement statement can be either a conditional expression statement or a command statement executed by another amount, or a command sequence that refers to one or more executable command lines. Also includes nested use of if or other process control statements
(2) Dual-branch if statement: for the two-branch selection structure, the requirements for the "condition is set" "condition is not established" to perform different operations respectively.
(3) Multi-branch If statement: Because the IF statement can be based on the test results of the establishment, do not set up separate operations, so can be nested use, make multiple judgments.

Shell Script 2

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.