ed.1 (2010 09)
e
ed(1) ed(1)
below.)
If an ampersand (
&) appears in replacement , it is replaced by the string matching the RE
on the current line. The special meaning of
& in this context can be suppressed by
preceding it with
\.
As a more general feature, the characters
\n, where n is a digit, are replaced by the text
matched by the nth regular subexpression of the specified RE enclosed between
\( and
\). When nested parenthesized subexpressions are present, n is determined by counting
occurrences of
\(, starting from the left.
When the character
% is the only character in replacement , the replacement used in the
most recent substitute command is used as the replacement in the current substitute com-
mand. The
% loses its special meaning when it is in a replacement string containing
more than one character or when preceded by a
\.
A line can be split by substituting a newline character into it. The newline in replace-
ment must be escaped by preceding it by
\. Such substitution cannot be done as part of a
g or v command list.
The value of flags is zero or more of:
n Substitute for the nth occurrence only of the RE found on each addressed line.
g Substitute for all nonoverlapped occurrences of the RE on each addressed line.
l Write to standard output the final line in which a substitution was made. The
line is written in the format specified for the l command.
n Write to standard output the final line in which a substitution was made. The
line is written in the format specified for the n command.
p Write to standard output the final line in which a substitution was made. The
line is written in the format specified for the p command.
(
.,.)ta Same as m command, except that a copy of the addressed lines is placed after address a
(which can be 0). Upon completion, the new current line is the last line of the copy.
u The u (undo) command nullifies the effect of the most recent command that modified any-
thing in the buffer, that is, the most recent a, c, d
, g, G, i, j, m, r, s, t, v,orV com-
mand. All changes made to the buffer by a
g, G, v,or
V global command are "undone" as
a single change; if no changes were made by the global command (such as with
g/
RE/p),
the
u command has no effect. The current line number is set to the value it had immedi-
ately before the command started.
(
1,$)v/RE/command-list
The complement of the global command g in that the lines marked during the first step
are those that do not match the RE.
(
1,$)V/RE/ The complement of the interactive global command G in that the lines marked during the
first step are those that do not match the RE.
(
1,$)w file The w (write) command writes the addressed lines into the named file. If the file does not
exist, it is created with mode 666 (readable and writable by everyone), unless the current
umask setting dictates otherwise (see umask(1). The remembered file name is not
changed unless file is the very first file name encountered since ed was invoked. If no
file name is given, the remembered file name, if any, is used (see the e and f commands).
Upon completion, the current line address is unchanged. If the command is successful,
the number of characters written is displayed.
If the file name starts with
!, the rest of the line is interpreted as a shell command whose
standard input is the addressed lines. Such a shell command is not remembered as the
current file name.
X A key string is demanded from the standard input. Subsequent e, r, and w commands
will encrypt and decrypt the text with this key, using the algorithm of crypt (1). An expli-
citly empty key turns off encryption.
(
$)= The line number of the addressed line is displayed. The current line address is
unchanged by this command.
HP-UX 11i Version 3: September 2010 − 5 − Hewlett-Packard Company 5