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:

Get Bash Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.