- Bash Quick Start Guide
- Tom Ryder
- 174字
- 2021-07-23 16:58:57
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: ```
推薦閱讀
- 現(xiàn)代測控系統(tǒng)典型應(yīng)用實(shí)例
- 過程控制工程及仿真
- 輕松學(xué)C#
- 7天精通Dreamweaver CS5網(wǎng)頁設(shè)計(jì)與制作
- Mastering VMware vSphere 6.5
- Dreamweaver CS3網(wǎng)頁設(shè)計(jì)與網(wǎng)站建設(shè)詳解
- ROS機(jī)器人編程與SLAM算法解析指南
- 基于ARM 32位高速嵌入式微控制器
- Excel 2007常見技法與行業(yè)應(yīng)用實(shí)例精講
- PowerMill 2020五軸數(shù)控加工編程應(yīng)用實(shí)例
- 數(shù)據(jù)要素:全球經(jīng)濟(jì)社會發(fā)展的新動力
- 設(shè)計(jì)模式
- Learning Cassandra for Administrators
- Learning Couchbase
- 電機(jī)與電力拖動