The difference between single quotes, double quotes, and anti-quotes in Linux

Source: Internet
Author: User
Tags echo command

1.single and double quotation marks are used for the user to assign a string with a space to the delimiter of the variable.

[email protected] sh]# str= "Today is Monday"
[email protected] sh]# echo $str
Today is Monday
If there is no single or double quotation marks, the shell interprets the string after the space as a command.
[email protected] sh]# Str=today is Monday
Bash:is:command not found


2, the difference between single and double quotation marks. Single quotes tell the shell to ignore all special characters, while double quotes ignore most but do not include $ \ '

The ' $ ' (parameter substitution) and ' ' ' (command substitution) are exceptions in double quotes, so there's basically no difference between the two, unless the parameter substitution $ and the command substitution are encountered in the content.

such as: num=3

Echo ' $num '

$num

echo "$num"
3
Therefore, if you need to use both symbols in the double quotation mark "", you need to escape with a backslash.


3.The back quotation marks (') are located above the TAB key of the keyboard and the left side of the 1 key. Note the difference between the single quotation mark (') on the left side of the ENTER key. plays the role of command substitution in Linux. Command substitution refers to the ability of the shell to interpolate the standard output of a command anywhere on a command line.
For example, the shell executes the date command in an inverted quotation mark and inserts the result into the content displayed by the echo command.
[email protected] sh]# echo the date is ' date '
The date is Monday, March 14, 2011 21:15:43 CST

The difference between single quotes, double quotes, and anti-quotes in Linux

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.