version 1.54, 2017/12/19 17:46:28 |
version 1.55, 2018/07/10 09:10:03 |
|
|
input lines |
input lines |
cumulatively across input files), a dollar character |
cumulatively across input files), a dollar character |
.Pq Ql $ |
.Pq Ql $ |
that addresses the last line of input, or a context address |
that addresses the last line of input, or a context address, |
(which consists of a regular expression preceded and followed by a |
which is a regular expression preceded and followed by a delimiter. |
delimiter). |
The delimiter can be any character except a newline or a backslash. |
|
Unless it is a slash, the opening delimiter needs to be escaped with |
|
a backslash. |
.Pp |
.Pp |
A command line with no addresses selects every pattern space. |
A command line with no addresses selects every pattern space. |
.Pp |
.Pp |
|
|
.Pp |
.Pp |
.Bl -enum -compact |
.Bl -enum -compact |
.It |
.It |
In a context address, any character other than a backslash |
The character delimiting the regular expression |
.Pq Ql \e |
can be used inside the regular expression by prepending a backslash |
or newline character may be used to delimit the regular expression. |
or by including it in a character class. |
The opening delimiter should be preceded by a backslash |
For example, in the context address \ex\ex[xy]x, the RE delimiter |
unless it is a slash. |
|
Putting a backslash character before the delimiting character |
|
causes the character to be treated literally. |
|
For example, in the context address \exabc\exdefx, the RE delimiter |
|
is an |
is an |
.Sq x |
.Sq x |
and the second |
and the other |
.Sq x |
.Sq x |
stands for itself, so that the regular expression is |
characters stand for themselves, so that the regular expression is |
.Dq abcxdef . |
.Dq x[xy] . |
.Pp |
.Pp |
.It |
.It |
The escape sequence \en matches a newline character embedded in the |
The escape sequence \en matches a newline character embedded in the |
|
|
in the pattern space. |
in the pattern space. |
Any character other than backslash or newline can be used instead of |
Any character other than backslash or newline can be used instead of |
a slash to delimit the regular expression and the replacement. |
a slash to delimit the regular expression and the replacement. |
Within the regular expression and the replacement, |
Also see the the section about |
the delimiter itself can be used as a literal character |
.Sx SED REGULAR EXPRESSIONS . |
if it is preceded by a backslash. |
|
.Pp |
.Pp |
An ampersand |
An ampersand |
.Pq Ql & |
.Pq Ql & |