官术网_书友最值得收藏!

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: ```
主站蜘蛛池模板: 玉山县| 北票市| 囊谦县| 台前县| 林甸县| 兴化市| 容城县| 富民县| 晋江市| 金山区| 漳浦县| 衡南县| 嘉兴市| 泸西县| 绥宁县| 陕西省| 如东县| 龙井市| 宝清县| 佛学| 观塘区| 灯塔市| 遂川县| 鹿邑县| 大方县| 墨竹工卡县| 永和县| 巴林左旗| 宁武县| 于田县| 三原县| 凤山县| 怀化市| 韶山市| 金寨县| 盐城市| 玉树县| 安西县| 保靖县| 崇仁县| 出国|