Shell-4.shell double quotes, single quotes, back quotes, backslashes

Source: Internet
Author: User

Shell double quotes, single quotes, back quotes, backslashes
<1> double quotation mark ""; allow referencing of other variable values through the $ symbol
<2> single quote ': Disallow reference to other variable values, $ as normal characters
<3>. Anti-quote ": Outputs the command execution result
<4&gt. Backslash \: Handles special characters and handles escape characters, for example: \ t \ n \ r


1. Double quotes ""
• Use double quotation marks to refer to any character or string other than $, ', \, character
[Email protected] ~]# name= "Yuanji"
[Email protected] ~]# echo "Hello, $name"
Hello,yuanji

2. Single quote '
• Similar to double quotation marks, the difference is that the shell ignores any reference values. In other words, if the special meaning is masked, all the characters in the quotation marks are used as a string
• Use all characters as normal characters for output
[Email protected] ~]# server= ' BJ_BGP '
[Email protected] ~]# echo "Server is @server"
Server is @server

3. Anti-quote '
• Used to set the output of system commands to variables. The shell takes the contents of the anti-quote as a system command and executes its contents
[[email protected] ~]# echo "It ' s ' Date '"
It's Friday May 13, 2016 14:08:59 CST

4. Anti-slash \
• If a character has a special meaning, the backslash prevents the shell from misunderstanding its meaning, which is to block its special meaning.
• The following characters contain special meanings:& * + ^ $ ' "|?

[[email protected] ~]# echo "This book price for $188.88" # $188.88 is actually 88.88 after the variable is
This book price for 88.88
[Email protected] ~]# echo "This book price for \$188.88"
This book price for $188.88

[[email protected] ~]# echo ' This book price for $188.88 ' #或者用单引号
This book price for $188.88

[Email protected] ~]# echo-e "Hello.\nwelcome to Shell."
Hello.
Welcome to Shell.

Here-e indicates the substitution of the escape character. If you do not use the-e option, it is output as-is:
[Email protected] ~]# echo "Hello.\nwelcome to Shell."
Hello.\nwelcome to Shell.

The use of ECHO will be described in a subsequent article
The above is a personal point of summary and understanding, the level is not high, the level of writing is very bad, please greatly forgive me.
Can exchange learning together.

My qq:610851588.
Can join my build group (now very few people, hope slowly more up)
Linux Clusters: 183932302
Python, Shell AC Group: 469094734

This article is from the "Go to the Origin dimension" blog, please make sure to keep this source http://yuanji6699.blog.51cto.com/11568362/1773022

Shell-4.shell double quotes, single quotes, back quotes, backslashes

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.