HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)
e
ed(1) ed(1)
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 replacement
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
,orV 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 explicitly
empty key turns off encryption.
($)= The line number of the addressed line is displayed. The current line address is unchanged
by this command.
!shell-command
The remainder of the line after the ! is sent to the shell to be interpreted and executed as a
command. Within the text of that command, the unescaped character % is replaced with
the remembered file name. If a ! appears as the first character of the shell command, it is
replaced with the text of the previous shell command. Thus, !! repeats the last shell com-
mand. If any expansion is performed, the expanded line is echoed. Upon completion, the
current line address is unchanged.
(.+1) newline An address alone on a line causes the addressed line to be printed. A newline alone is
equivalent to .+1p. This technique is useful for stepping forward through the buffer.
HP-UX 11i Version 1: September 2005 − 5 − Hewlett-Packard Company Section 1−−207