5.6.1. sed addressesΒΆ
To limit the extent of an command, we have to use addresses. A command can accept zero, one or two addresses. An address can be a regular expression or a line-number.
if no address is specified, the command is executed for each line
if one address is specified, the command is applied for each line matching the address
if two addresses are specified, the command is performed to the first line and all following lines up to and including the second match
if an addres is followed by a
!
, the command is used on all lines that do not match the address
Some examples (using the d
command, which delets the matching line(s):
$d deletes the last line of the input ($ means the last line)
11,$d deletes all lines from line 11 (so keeping the first 10 lines)
/^$/d deletes all blank lines; a regexp is enclosed in
/