在bash参考手册中有如下说明:
Enclosing characters in single quotes (‘'’) preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash.
(在单引号中的字符保持字面值,不会对bash中的特殊字符进行解析(shell expansion等),同时单引号不能嵌套,及时有反斜杠转移单引号也不行)
Enclosing characters in double quotes (‘"’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’. The characters ‘$’ and ‘`’ retain their special meaning within double quotes (see Shell Expansions). The backslash retains its special meaning only when followed by one of the following characters: ‘$’, ‘`’, ‘"’, ‘\’, or newline. Within double quotes, backslashes that are followed by one of these characters are removed. Backslashes preceding characters without a special meaning are left unmodified. A double quote may be quoted within double quotes by preceding it with a backslash. If enabled, history expansion will be performed unless an ‘!’ appearing in double quotes is escaped using a backslash. The backslash preceding the ‘!’ is not removed.
The special parameters ‘*’ and ‘@’ have special meaning when in double quotes (see Shell Parameter Expansion).
(在双引号中的字符除了$,`(倒引号),\(反斜杠),! 之外其他的字符保持其字面值。在 bash中可以使用反斜杠来对之前的特殊字符转义,反斜杠只有针对$,倒引号,反斜杠,感叹号,双引号和单引号的时候才会有特殊含义,否则被当做一般字符看待。