Linux single quotes, double quotes, and reverse quotes

Source: Internet
Author: User

Single quotes

Purpose: To prevent text conversion. Except for the single quotation marks, all words in the single quotation marks are output as is.

1. [root @ jszwl161 sp49ep9] # echo '$ *> <! '

$ *> <!

2. [root @ jszwl161 sp49ep9] # echo 'she is crying: "Help "'

She is crying: "Help"

3. [root @ jszwl161 sp49ep9] # echo '\\\\'

\\\\

4. [root @ jszwl161 sp49ep9] # echo 'hah'test''

Hah test # skipped all'

5. [root @ jszwl161 sp49ep9] # echo 'Today is 'date''

Today is 'date' # The function cannot be implemented here.

Double quotation marks

Purpose: To include text or function segments, except for functions in the backquotes, variables starting with $, and characters in the backticks are directly output.

1. [root @ jszwl161 sp49ep9] # echo "Today is 'date '"

Today is Fri Jul 4 08:03:34 GMT 2008

2. [root @ jszwl161 sp49ep9] # echo "Today is 'date '"

Today is 'date'

3. [root @ jszwl161 sp49ep9] # echo "\\\\"

\\

4. [root @ jszwl161 sp49ep9] # echo "test" test ""

Test test

Reverse quotation marks

The objective is to keep Function Conversion within double quotes, but it does not work in single quotes.

1. [root @ jszwl161 sp49ep9] # echo "Today is 'date '"

Today is Fri Jul 4 08:03:34 GMT 2008 # convert the function date.

2. [root @ jszwl161 sp49ep9] # echo 'Today is 'date''

Today is 'date' # It does not work in single quotes.

 

 

 

Single quotes

The content enclosed by single quotes is considered as a single string. The $ symbol representing the variable in quotation marks does not work. That is to say, it is treated as a general symbol to prevent replacement of any variable.

Double quotation marks
The content enclosed by double quotation marks is considered as a single string. It prevents wildcard extension, but allows variable extension. This is different from how a single reference is processed.

Reverse quotation marks
The preceding single double quotes enclose strings. What if the string is a command column? The answer is no execution. To deal with this situation, we must use reverse single quotes.
Fdv = 'date + % F' echo "today $ fdv"

The date + % F in the inverted quotation marks is considered as an instruction, and the execution result is included in the fdv variable.

Address: http://kmoving.blog.163.com/blog/static/205049197201242211111682/

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.