Tips for the basics of Shell programming

Source: Internet
Author: User

    • Exit status
      The built-in command in bash does not create a new process, but it also has the exit status, usually with 0 to indicate that a success nonzero indicates a failure, although the built-in command does not create a new process, but there is a status code after execution, or it can be read with a special variable $?
    • command substitution: ' or $ ()
       [email protected]:~$ echo  ' 
    • Arithmetic substitution: $ (())
       [email protected]:~$ echo  $ ((1  +1  ))  2  
       [email protected]:~$ i=1  [email  protected]:  ~$ echo  $ (($i +1   2   ~$ echo  $ ((I+1   2  
  • Single quotation marks
    The single and double quotation marks in a shell script are the same as the delimiter of the string, not the delimiter of the character. Single quotation marks are used to hold the literal value of all characters within the quotation marks, even if the \ and carriage returns within the quotation marks are no exception, but single quotes cannot appear in the string. If the quotation marks are entered without pairing, the shell gives a continuation prompt that asks the user to match the quotation marks. For example:
    Echo ' Hello Word ' Hello Word[email protected]:~$
    Echo ' Hello \> Word'hello word[email protected]:~$
  • Double quotes
    Double quotation marks are used to keep the literal value of all characters in quotation marks (carriage return is no exception), except in the following cases:
    • $ plus variable name to take the value of the variable
    • Anti-quotation marks still indicate command substitution
    • \$ represents the literal value of $
    • The literal value of \ ' representation '
    • The literal value of \ "represents"
    • \ \ denotes the literal value of \
  • [Email protected]:~$Echo$HOME/home/User[email protected]:~$Echo "' Date '"Sat Oct -  +: to: $Cst the[email protected]:~$Echo "I ' d say: \ "Go for it\""I'D say: "Go for it"[Email protected]:~$Echo "\">""[email protected]:~$Echo "\\"[email protected]:~$

Tips for the basics of Shell programming

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.