Special Characters and Quoting

The characters <, >, |, and & are four examples of special characters that have particular meanings to the shell. The wildcards we saw earlier in this chapter (*, ?, and [...]) are also special characters.

Table 1-6 gives the meanings of all special characters within shell command lines only. Other characters have special meanings in specific situations, such as the regular expressions and string-handling operators that we'll see in Chapter 3 and Chapter 4.

广告:个人专属 VPN,独立 IP,无限流量,多机房切换,还可以屏蔽广告和恶意软件,每月最低仅 5 美元

Table 1-6. Special characters

Character

Meaning

See chapter

~

Home directory

Chapter 1

`

Command substitution (archaic)

Chapter 4

#

Comment

Chapter 4

$

Variable expression

Chapter 3

&

Background job

Chapter 1

*

String wildcard

Chapter 1

(

Start subshell

Chapter 8

)

End subshell

Chapter 8

\

Quote next character

Chapter 1

|

Pipe

Chapter 1

[

Start character-set wildcard

Chapter 1

]

End character-set wildcard

Chapter 1

{

Start command block

Chapter 7

}

End command block

Chapter 7

;

Shell command separator

Chapter 3

`

Strong quote

Chapter 1

<">

Weak quote

Chapter 1

<

Input redirect

Chapter 1

>

Output redirect

Chapter 1

/

Pathname directory separator

Chapter 1

?

Single-character wildcard

Chapter 1

!

Pipeline logical NOT

Chapter 5