Linux single quotes, double quotes, anti-quotes

Source: Internet
Author: User

Single quotation marks
Purpose: In order to protect the text from being converted. That is, except for the single quote, all the text inside the single quotation marks is output as is.
1. [[email protected] sp49ep9]# echo ' $*><! '
$*><!
2. [[email protected] sp49ep9]# echo ' She's crying: ' Help '
She is crying: "Help"
3. [[Email protected] sp49ep9]# echo ' \\\\ '
\\\\
4. [[Email protected] sp49ep9]# echo ' hah ' test '
Hah Test #略去了所有 '
5. [[Email protected] sp49ep9]# echo ' Today is ' date '
Today is ' Date ' #反引号在此无法实现函数功能.

double quotes
Span style= "font-family: ' Microsoft Jacob Black ', Sans-serif;" Purpose: To include text or function segments. In addition to itself, the function inside the counter-quote, the variable starting with $ and the \ Start inverse of the character, the rest is the direct output.
1. [[email protected] sp49ep9]# echo "Today is ' Date '"
    today is Fri jul    4 08:03:34 GMT
2. [[email protected] sp49ep9]# echo "Today is ' Date '"
    today is ' Date '
3. [[email protected] sp49ep9]# echo "\\\\"
    \\
4. [[email protected] sp49ep9]# echo "test" test ""
    test test


Anti-Quote
The purpose is to keep the function transformation within the double quotation marks. But it has no effect in single quotation marks.
1. [[email protected] sp49ep9]# echo "Today is ' Date '"
Today is Fri Jul 4 08:03:34 GMT2008 #将函数date转换.
2. [[email protected] sp49ep9]# echo ' Today is ' date '
Today is ' Date ' #在单引号内无作用.

Single quotation marks

The enclosed quotation marks are treated as a single string. The $ sign that represents the variable within the quotation marks does not work, that is, he is treated as a general symbol and prevents any variable substitution.
Double quotes
The content enclosed in double quotes is treated as a single string. It prevents wildcard expansion, but allows variable expansion. This is different from the way a single argument is handled.
Anti-Quote
In the preceding single double quotation mark, enclose the string, but what if the string is a list of command columns? The answer is no execution. To deal with this situation, we have to use anti-single quotes to do it.
fdv= ' Date +%f ' echo "Today $FDV"
The date +%f in the inverted quotation marks is treated as an instruction, and the result of execution is taken into the FDV variable.


This article is from the "Itlang_jansion_goktech" blog, make sure to keep this source http://wangdy.blog.51cto.com/3845563/1570637

Linux single quotes, double quotes, anti-quotes

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.