Linux: Bash details-extremely important and error-prone

Source: Internet
Author: User

Variable Operators

The parent shell script always runs in the sub-shell environment. The sub-shell can only see copies of environment variables, but cannot see local variables of the parent shell; the parent shell can not see local variables of the sub-shell, but can see the environment variables exported by the sub-shell

Braces extended {}, priority higher than variable replacement! The left and right braces {} must be closely linked with each other and cannot be blank. The content must also be tightly linked by commas!

Shell variables are strings by default. You can use double quotation marks ("string") or single quotation marks ("string") to specify them. The difference between the two is that double quotation marks ("string") support $ variable extension!

Variable extension $ {} the Left and Right braces {} must be closely linked with the variable identifier. No blank space is allowed! By default, bash recognizes variable names as words!

The test expression operator "[express]" must be blank with other express!

The test expression operator "[express]" must be blank with other express! In addition, there must be a blank space between operators and variables in express; otherwise, you are dead!

 

Use the variable as the value type to calculate "$ [express]". Leave no blank between express and both sides!

The 'command' is used to execute commands and obtain command output information. There is a blank space between the command and the 'symbol!

Strings that are not enclosed in quotation marks after the command are wildcard "*,?" , Remember! If you do not want to use quotation marks, you can use escape characters to escape these wildcards.

 

 

 

By default, bash runs one command in one line. You can use the Semicolon ";" to write multiple commands in one line and execute each command from left to right!

& The separator tells bash that only the preceding command is successfully executed can the subsequent command be executed; it is the operator form of the IF statement

| The delimiter tells bash that only the execution of the preceding command fails to execute the following command; it is the operator form of the IF statement

The special operator "string)" in the case statement and the break statement operator ";". "String)" cannot be blank between the string and the operator; the break operator can be left blank!

The hereisdocument operator "<identity... Identity" is similar to a pipe

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.