ed.1 (2010 09)
e
ed(1) ed(1)
(.)a
text
.
The a (append) command reads text and appends it after the addressed line. Upon com-
pletion, the new current line is the last inserted line, or, if no text was added, at the
addressed line. Address 0 is legal for this command, causing the appended text to be
placed at the beginning of the buffer.
(
.,.)c
text
.
The c (change) command deletes the addressed lines then accepts input text to replace
the deleted lines. Upon completion, the new current line is the last line in text or, if no
text was provided, at the first line after the deleted line or lines. Address 0 would be
interpreted as address 1.
(
.,.)d The d (delete) command deletes the addressed lines from the buffer. Upon completion,
the new current line is the first line following the deleted text, or the last line in the file if
the deleted line or lines were at the end of the buffer.
e file The e (edit) command deletes the entire contents of the buffer, then reads in the named
file. Upon completion, the new current line is the last line in the buffer. If no file name
is given, the remembered file name, if any, is used (see the
f command). The number of
characters read is displayed, and file is remembered for possible use as a default file
name in subsequent
e, r,or
w commands.
If the file name starts with
!
, the rest of the line is interpreted as a shell command whose
standard output is to be read. Such a shell command is not remembered as the current
file name.
Also see DIAGNOSTICS below.
E file The E (forced edit) command is identical to e except that no check is made to ensure that
the current buffer has not been altered since the last w command.
f file If file is specified, the f (file name) command changes the remembered file name to file.
Otherwise, it prints the remembered file name.
(
1,$)g/RE/command-list
The g (global) command first marks every line that matches the given RE. Then, for
every such line, the given command-list is executed with the current line initially set to
that line. A single command or the first of a list of commands appears on the same line
as the global command. All lines of a multiple-line list except the last line must end with
a backslash (\). a, i, and c commands and associated input are permitted. The
. that
normally terminates input mode can be omitted if it would be the last line of the
command-list . An empty command-list is equivalent to the
p command. The g, G, v
,
and
V commands are not permitted in the command-list . (Also see WARNINGS below.)
(
1,$)G/RE The interactive G (Global) command first marks every line that matches the given RE.
Then, for every such line, the line is printed, then the current line is changed to that line
and one command (other than a, c, i, g, G, v
,orV) can be input and executed. After
executing that command, the next marked line is printed, and so on. A newline character
acts as a null command, and an
& causes the re-execution of the most recent command
executed within the current invocation of G. Note that the commands input as part of the
execution of the G command may address and affect any lines in the buffer. The G com-
mand can be terminated by an interrupt signal (ASCII DEL or BREAK).
h The h (help) command gives a short error message explaining the reason for the most
recent ? diagnostic.
H The H (Help) command causes ed to enter a mode in which error messages are printed
for all subsequent ? diagnostics. It also explains the previous ? if there was one. The H
command alternately turns this mode on and off. Initially, it is off.
(
.)i
text
.
The i (insert) command inserts the given text before the addressed line. Upon comple-
tion, the current line is the last inserted line, or, if there were none, the addressed line.
This command differs from the a command only in the placement of the input text.
Address 0 is not legal for this command.
Under the UNIX 2003 environment (see standards (5)), the
i (insert) command interprets
address 0 as address 1.
(
.,.+1)j The j (join) command joins contiguous lines by removing the appropriate newline charac-
ters. If exactly one address is given, this command does nothing.
HP-UX 11i Version 3: September 2010 − 3 − Hewlett-Packard Company 3