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.
Table 1-6. Special Characters
| Character | Meaning | See Chapter |
|---|---|---|
| ~ | Home directory | 1 |
| ` | Command substitution (archaic) | 4 |
| # | Comment | 4 |
| $ | Variable expression | 3 |
| & | Background job | 1 |
| * | String wildcard | 1 |
| ( | Start subshell | 8 |
| ) | End subshell | 8 |
| \ | Quote next character | 1 |
| | | Pipe | 1 |
| [ | Start character-set wildcard | 1 |
| ] | End character-set wildcard | 1 |
| { | Start command block | 7 |
| } | End command block | 7 |
| ; | Shell command separator | 3 |
| ' | Strong quote | 1 |
| <"> | Weak quote | 1 |
| < | Input redirect | 1 |
| > | Output redirect | 1 |
| / | Pathname directory separator | 1 |
| ? | Single-character wildcard | 1 |
| ! | Pipeline logical NOT | 5 |
Quoting
Sometimes you will want to use special characters literally, i.e., without their special meanings. This is called quoting. If you surround a string of characters with single quotation marks (or quotes), you strip all characters within the quotes of any special meaning they might have.
The most obvious situation where you might need to quote a string is with the echo command, which just takes its arguments and prints them to the standard output. What is the ...