References in shell

Source: Internet
Author: User
Shell quotes 1. double quotation marks $, ', \, reserved for special purpose. Note that [root @ Centos5test] # echo & quot; \ n & quot; is supported by the escape character "\ n" by default when echo is not added; \ n [root @ Centos5test] # [root @ Centos5test] # printf & quot; \ n & quot ;...

 

Quotes in shell

1. double quotation marks

$, ', \, Retain special meaning

Note that escape characters such as \ n are not supported by default when echo is not added.

Supported by printf

[Root @ Centos5 test] # echo "\ n"

\ N

[Root @ Centos5 test] #

[Root @ Centos5 test] # printf "\ n"

 

[Root @ Centos5 test] #

Note that special characters echo "\ Special characters" are referenced in double quotation marks"

# Special characters $ '\ "are known in double quotes

Echo "\""

"

Echo "\ $"

$

2. single quotes

The referenced character is interpreted as the surface meaning of the character.

Note that escape characters such as \ n are interpreted in both single quotes and double quotes during echo-e.

Escape tables

\ A \ B \ c \ f \ n \ t \ r \ v

# Do not confuse with \ $

[Root @ Centos5 test] # echo-e "\ n"

 

[Root @ Centos5 test] #

[Root @ Centos5 test] # echo-e '\ n'

 

[Root @ Centos5 test] # echo-e '\"'

\"

Then

[Root @ Centos5 test] # echo-e '\'

\

[Root @ Centos5 test] # echo-e '\\'

\

[Root @ Centos5 test] # echo \

>

Don't be confused.

3. unified symbol

Do not use it *? [] | ^. If no match is found, it is interpreted as itself.

 

[Root @ Centos5 test] # ls *. 111

Ls: *. 111: No such file or directory

4. escape \, \ the next character is interpreted as literal

Echo \*

*

Echo \\

\

5. shell metacharacter meta

IFS

CR

=

$

>

<| & () {}; & |!

# Escape these characters when they are not referenced

Echo \ =

=

I don't know about some output, so I will try it. The results will come out several times.

This article is from the blog "The gentleman is knowledgeable and the Japanese ginseng saves himself ...".

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.