上QQ阅读APP看书,第一时间看更新
Double quotes
Double quotes behave similarly to single quotes, but they perform certain kinds of expansion within them, for shell variables and substitutions. This can be used to include the value of a variable as part of a literal string:
$ echo "This is my login shell: $SHELL" This is my login shell: /bin/bash
Compare this to the literal output of single quotes:
$ echo 'This is my login shell: $SHELL' This is my login shell: $SHELL
Other kinds of parameter expansion within double quotes are possible, which we will examine in later chapters.
You can include a literal dollar sign or backslash in a string by escaping it:
$ echo "Not a variable: \$total" Not a variable: $total $ echo "Back\\to\\back\\slashes" Back\to\back\slashes
Exclamation marks are a special case, due to history expansion; you will generally need to quote them with a backslash or single quotes instead of double quotes:
$ echo "Hello $USER"'!!' Hello bashuser!!
For historical reasons, you will also need to escape backtick characters (`):
$ echo "Backticks: \`\`\`" Backticks: ```