linux-the difference between single quotes, double quotes, and anti-quotes.

Source: Internet
Author: User

One, single and double quotation marks

Both single and double quotes are meant to solve the problem of having spaces in the middle.

Because the space in Linux as a very typical delimiter, such as String1=this is astring, so execution will be error. To avoid this problem, single and double quotes are generated. Their difference is that the single

The quotation marks deprive the special meaning of all characters, while the ' $ ' (parameter substitution) and ' ' (command substitution) in double quotation marks are the exception. So, there's basically no difference between the two, unless the parameter substitution $ and the command substitution are encountered in the content

'.

So here's the result:
Num=3
Echo ' $num '
$num
echo "$num"
3
Therefore, if you need to use both of these symbols in the double quotation mark "", you need to escape with a backslash.

Second, anti-quote "'

The usage of this thing, and $ () is the same. When you execute a command, the statements in either, or $ () are executed once as a command, and the result is added to the original command for re-execution.

For example: Echo ' ls ' will first execute LS to get xx.sh and so on, then replace the original command as: Echo xx.sh the last execution result is xx.sh so, usually we encounter the output of a bunch of command execution results in a variable, need to use this

The command substitution is also understandable.

linux-the difference between single quotes, double quotes, and 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.