.\" @(#)sed.1 6.1 (Berkeley) %G%
(standard input default) to the standard output,
edited according to a script of commands.
option causes the script to be taken from file
these options accumulate.
option suppresses the default output.
A script consists of editing commands, one per line,
[address [, address] ] function [arguments]
cyclically copies a line of input into a
(unless there is something left after
select that pattern space,
and at the end of the script copies the pattern space
to the standard output (except under
and deletes the pattern space.
is either a decimal number that counts
input lines cumulatively across files, a `$' that
addresses the last line of input, or a context address,
`/regular expression/', in the style of
The escape sequence `\en' matches a
newline embedded in the pattern space.
A command line with no addresses selects every pattern space.
one address selects each pattern space that matches the address.
two addresses selects the inclusive range from the first
pattern space that matches the first address through
the next pattern space that matches
(If the second address is a number less than or equal
to the line number first selected, only one
Thereafter the process is repeated, looking again for the
Editing commands can be applied only to non-selected pattern
spaces by use of the negation function `!' (below).
In the following list of functions the
maximum number of permissible addresses
for each function is indicated in parentheses.
consists of one or more lines,
all but the last of which end with `\e' to hide the
Backslashes in text are treated like backslashes
in the replacement string of an `s' command,
and may be used to protect initial blanks and tabs
against the stripping that is done on
must terminate the command
line and must be preceded by exactly one blank.
is created before processing begins.
There can be at most 10 distinct
reading the next input line.
Branch to the `:' command bearing the
is empty, branch to the end of the script.
Delete the pattern space.
With 0 or 1 address or at the end of a 2-address range, place
Delete the pattern space.
Delete the initial segment of the
pattern space through the first newline.
Replace the contents of the pattern space
by the contents of the hold space.
Append the contents of the hold space to the pattern space.
Replace the contents of the hold space by the contents of the pattern space.
Append the contents of the pattern space to the hold space.
Copy the pattern space to the standard output.
Replace the pattern space with the next line of input.
Append the next line of input to the pattern space
with an embedded newline.
(The current line number changes.)
Copy the pattern space to the standard output.
Copy the initial segment of the pattern space through
the first newline to the standard output.
Branch to the end of the script.
Do not start a new cycle.
Place them on the output before reading
.RI (2)\|s /regular\ expression/replacement/flags
string for instances of the
Any character may be used instead of `/'.
For a fuller description see
Substitute for all nonoverlapping instances of the
Print the pattern space if a replacement was made.
Append the pattern space to
Branch to the `:' command bearing the
substitutions have been made since the most recent
reading of an input line or execution of a `t'.
is empty, branch to the end of the script.
Append the pattern space to
Exchange the contents of the pattern and hold spaces.
.RI (2)\|y /string1/string2/
Replace all occurrences of characters in
with the corresponding character in
selected by the address(es).
This command does nothing; it bears a
for `b' and `t' commands to branch to.
Place the current line number on the standard output as a line.
Execute the following commands through a matching `}'
only when the pattern space is selected.
An empty command is ignored.
ed(1), grep(1), awk(1), lex(1)