The shell must read at first, it is highly recommended for beginners to read

Source: Internet
Author: User

Background:

A lot of people have been converted from C + +, after reading the study document, stepping into a lot of pits

1 assigning values to variables don't have spaces

# correct a = 123    #  error

2 if statement [] to leave a space, the variable is best to add ""

if " $a "-eq"  #  pair if [$a-eq]      #  wrong

3 in many cases want to output "! "This is a time to use single quotes

Echo ' ok! '        #对的echo "error!"  # of the wrong

4 position parameter more than 10 to use the curly braces less than 10 can not

Echo ${10}     # is correct, indicating that the 10th variable is printed echo $         # is also correct, but represents the first variable followed by a 0

5 Remember that uninitialized variables are null, not 0

6 double quotes in an if statement

if " $a " ]        #  Right if [-N $a]           # Error

7 Child shell operations do not affect the parent shell

Child Shell:

# !/bin/bash string_test="TEST"export string_test

Parent Shell:

Echo $STRING _test

8 DOS-style \ r \ n is not legal in bash

Dos2unix need to convert

9 spaces appear in parameter passing

The above content appears in

The shell must read at first, it is highly recommended for beginners to read

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.