- 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í)例
- 火格局的時(shí)空變異及其在電網(wǎng)防火中的應(yīng)用
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)·基礎(chǔ)模塊
- 手把手教你學(xué)AutoCAD 2010
- 讓每張照片都成為佳作的Photoshop后期技法
- Spark大數(shù)據(jù)技術(shù)與應(yīng)用
- 傳感器與新聞
- 單片機(jī)原理實(shí)用教程
- The DevOps 2.1 Toolkit:Docker Swarm
- 簡明學(xué)中文版Photoshop
- 重估:人工智能與賦能社會(huì)
- 手把手教你學(xué)Photoshop CS3
- 常用傳感器技術(shù)及應(yīng)用(第2版)
- Windows 7故障與技巧200例
- Mastering MongoDB 4.x