Go to the first, previous, next, last section, table of contents.
Addresses in a SED script can be in any of the following forms:
1~2
;
to pick every third line starting with the second, 2~3
would be used;
to pick every fifth line starting with the tenth, use 10~5
;
and 50~0
is just an obscure way of saying 50
.
/
characters,
each must be escaped by a backslash (\
).
%
may be replaced by any other single character.)
This also matches the regular expression regexp,
but allows one to use a different delimiter than /
.
This is particularly useful if the regexp itself contains
a lot of /
s, since it avoids the tedious escaping of every /
.
If regexp itself includes any delimiter characters,
each must be escaped by a backslash (\
).
I
modifier to regular-expression matching is a GNU
extension which causes the regexp to be matched in
a case-insensitive manner.
If no addresses are given, then all lines are matched; if one address is given, then only lines matching that address are matched.
An address range can be specified by specifying two addresses
separated by a comma (,
).
An address range matches lines starting from where the first
address matches, and continues until the second address matches
(inclusively).
If the second address is a regexp, then checking for the
ending match will start with the line following the
line which matched the first address.
If the second address is a number less than (or equal to)
the line matching the first address,
then only the one line is matched.
Appending the !
character to the end of an address
specification will negate the sense of the match.
That is, if the !
character follows an address range,
then only lines which do not match the address range
will be selected.
This also works for singleton addresses,
and, perhaps perversely, for the null address.
Go to the first, previous, next, last section, table of contents.