Shell Learning Note 1

Source: Internet
Author: User

Brief description of single quotes, double quotes, and unquoted

Name Explain
Single quotation marks What you see is what you get: Everything inside a single quote is output as it is, or what you see in single quotes.
Anti-Quote Command substitution, which refers to the ability of the shell to interpolate the standard output of a command anywhere on a command line.
Double quotes Output all the contents of the double quotation marks, and if there are commands in the content (to be reversed), variables, special escape characters, etc., the variables, commands are parsed out, and then the final content is output.
No quotation marks Output of the content, the string containing the space as a whole output, if the contents of the command, variables, etc., will first parse the variables, commands, and then output the final content, if the string with a space and other special characters, you can not completely output, need to add double quotation marks, general continuous string, number, The path can be without any quotation marks, but it is best to use double quotes instead of quotation marks.
Tips The conclusion here is only empirical, and may not be appropriate for some languages, for example: there is a peculiarity within awk.

Example:

[Email protected] ~]# x=*

[Email protected] ~]# echo $x

Public template video Picture document download music Desktop

[Email protected] ~]# echo ' $x '

$x

[Email protected] ~]# echo "$x"

*

Example of anti-single quotes:

echo "Date +%y%m%d" double quotes

echo "date +%y%m%d" double quotes

Date +%y%m%d

echo ' date +%y%m%d ' single quote

Date +%y%m%d

echo ' Date +%y%m%d ' inverted single quote

20160811


Shell Learning Note 1

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.