- Bash Quick Start Guide
- Tom Ryder
- 174字
- 2021-07-23 16:58:57
Single quotes
Using single quotes, we could write the commands like this, which is perhaps more readable than the backslashes version, and creates files with identical names:
$ touch 'important files' $ touch 'Testfile<Tom>.doc' $ touch 'Review;Final.doc' $ touch '$$$Money.doc'
Unlike backslashes, single quotes can escape a newline in a word:
$ echo 'quotes > foo > bar' quotes foo bar
How do we use a single quote (') as a literal character between two single quotes? If you are coming to Bash from a language such as Perl or PHP, you might try it like this, with a backslash, but that doesn't work:
$ echo 'It\'s today' >
This is because backslash is not treated specially within single quotes. Doubling the single quote doesn't work, either:
$ echo 'It''s today' Its today
In this case, Bash just sees two single-quoted strings, It and s today, and pushes them together as one word. The way to do it is to use a backslash outside of the single quotes:
$ echo 'It'\''s today' It's today
推薦閱讀
- 自動(dòng)控制工程設(shè)計(jì)入門
- 計(jì)算機(jī)應(yīng)用復(fù)習(xí)與練習(xí)
- 網(wǎng)上生活必備
- Cloud Analytics with Microsoft Azure
- 智能工業(yè)報(bào)警系統(tǒng)
- RPA:流程自動(dòng)化引領(lǐng)數(shù)字勞動(dòng)力革命
- Arduino &樂高創(chuàng)意機(jī)器人制作教程
- OpenStack Cloud Computing Cookbook
- Salesforce for Beginners
- Dreamweaver CS6精彩網(wǎng)頁制作與網(wǎng)站建設(shè)
- 精通數(shù)據(jù)科學(xué):從線性回歸到深度學(xué)習(xí)
- 格蠹匯編
- 嵌入式GUI開發(fā)設(shè)計(jì)
- Dreamweaver+Photoshop+Flash+Fireworks網(wǎng)站建設(shè)與網(wǎng)頁設(shè)計(jì)完全實(shí)用
- 貫通開源Web圖形與報(bào)表技術(shù)全集