Monday 14 August 2017

Bash Single and Double Quoting

Cited from the Book "Pro Bash Programming"

All characters inside a single-quoted word are taken literally. A single-quoted word cannot contain a single quote even if it is escaped; the quotation mark will be regarded as closing the preceding one, and another single quote opens a new quoted section. Consecutive quoted words without any intervening whitespace are considered as a single argument.

In bash, single quotes can be included in words of the form $'string' if they are escaped. $ echo $'\'line1\'\n\'line2\''
'line1'
'line2'

No comments:

Post a Comment