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

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
主站蜘蛛池模板: 天气| 随州市| 石林| 平塘县| 芜湖县| 剑河县| 临西县| 万全县| 嘉祥县| 格尔木市| 车险| 多伦县| 鸡西市| 诏安县| 凌云县| 南部县| 台南市| 克拉玛依市| 罗江县| 德保县| 高密市| 濮阳市| 兴和县| 泾川县| 石渠县| 龙川县| 洮南市| 山阴县| 城固县| 文登市| 清河县| 疏勒县| 微山县| 连江县| 邢台县| 博罗县| 东阳市| 富顺县| 巴马| 龙岩市| 南华县|