Reputation:
An answer in this stackoverflow question In a Linux shell how can I process each line of a multiline string? mentions that $'\n'
is a special syntax "is not available in every shell".
I wonder what does the syntax mean?
Thank you.
Upvotes: 7
Views: 11324
Reputation: 311645
See the QUOTING
section of the bash
man page:
Words of the form $'string' are treated specially. The word expands to
string, with backslash-escaped characters replaced as specified by the
ANSI C standard. Backslash escape sequences, if present, are decoded as
follows:
...
\n new line
...
The expanded result is single-quoted, as if the dollar sign had not been
present.
This syntax is not part of the standard Unix Bourne shell. It may be specific to bash, although I haven't looked around to see if other shells support it.
Upvotes: 15