A script consists of editing
commands, one per line, of the following form:
[ address [ , address
] ] command [ arguments ]
Zero or more blank characters
are accepted before the first address and before command. Any number of
semicolons are accepted before the first address.
In normal operation, sed
cyclically copies a line of input (less its terminating NEWLINE character)
into a pattern space (unless there is something left after a D command),
applies in sequence all commands whose addresses select that pattern space,
and copies the resulting pattern space to the standard output (except under
-n) and deletes the pattern space. Whenever the pattern space is written
to standard output or a named file, sed will immediately follow it with
a NEWLINE character.
Some of the commands use
a hold space to save all or part of the pattern space for subsequent retrieval.
The pattern and hold spaces will each be able to hold at least 8192 bytes.
sed Addresses
An address is either empty,
a decimal number that counts input lines cumulatively across files, a $
that addresses the last line of input, or a context address, which consists
of a /regular expression/ as described on the regexp(5) manual page.
A command line with no addresses
selects every pattern space.
A command line with one address
selects each pattern space that matches the address.
A command line with two addresses
selects the inclusive range from the first pattern space that matches the
first address through the next pattern space that matches the second address.
Thereafter the process is repeated, looking again for the first address.
(If the second address is a number less than or equal to the line number
selected by the first address, only the line corresponding to the first
address is selected.) Typically, address are separated from each other
by a comma (,). They may also be separated by a semicolon (;).