Shell Learning Note III (escaping and referencing)

Source: Internet
Author: User

Tag:shell    reference     escape     command replace    

Escape and reference two types of characters: normal character and escape character escaping: "\" Example: 1, Echo $Dollar 2, echo \ $Dollar 3, Ech        O? Characters that need to be escaped: * $ () \ ' "? + ! # & [] {} < > |;        /NOTE:!#: reference: Refers to a string enclosed in a symbol to prevent special characters from being parsed into other meanings.        Four types: double quotes, single quotes, anti-quotes, escape characters where double quotes are called partial references or weak references, you can reference all characters except $, anti-quotes, escape characters, all characters can be referred to by a single quotation mark, or a strong reference, and an anti-quote interprets the contents of the backslash as a system command.                1, partial reference $, ', \ These three special characters will still be resolved to special characters note: var= "A b C" Echo $VAR;//a B C        echo "$VAR";//a B C 2, full reference all characters are ordinary characters echo ' $var ';//$var command substitution:        1, ' Example: var= ' Date ' 2, $ () array is ${} example: var=$ (date)        When the command output is multiple rows, if the variable is not output by reference, the output will delete the newline character, and the file name will be populated with the system default NULL, which means that the output contains only one row.             Example: #LS = ' LS ' #echo $LS algorithm awk.txt crontab.class Crontab.java crontab.txt #echo "$LS" AlgorIthm awk.txt crontab.class Crontab.java crontab.txt $ () support nesting, while ' unsupported, and '         Single quotes similar, not recommended for complex cases: fir=$ (wc-l $ (ls | sed-n ' 1p '))

Shell Learning Note III (escaping and referencing)

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.