| Using GNU sed version 4.0.5, you can
use '\n' to denote a newline character in
- a character class, and
- the replacement part of the substitution command 's'.
This feature conforms to 'the single UNIX specification, version 2
of the Open Group, where the sed specification says:
The escape sequence '\n' matches a newline character
in the pattern space. A literal newline character must not be
used in the regular expression of a context address or in
the substitute command.
In versions of GNU sed prior to 3.02.80,
you have to use '\' followed by an ENTER to express a newline
character in the replacement part of command 's'.
For example, to add a newline character to the end of every line,
changing from
Line 1 AAA
Line 2 BBB
Line 3 CCC
Line 4 DDD
| to be
Line 1 AAA
Line 2 BBB
Line 3 CCC
Line 4 DDD
|
you have to use
s/$/\
/
when using older versions of sed, while you can just use
s/$/\n/ in GNU sed version
4.0.5.
|