HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)
e
ed(1) ed(1)
Long lines are folded with the point of folding indicated by writing a backslash character
followed by a newline. The end of each line is marked with a
$.Anl (ell) command can be
appended to any command other than
e,
E, f, q, Q, r, w,or!. The current line number is
set to the address of the last line written.
Escape ASCII Escape ASCII
Sequence Represents Name Sequence Represents Name
\\ backslash \ \r carriage return CR
\a alert BEL \t horizontal tab HT
\b backspace BS \v vertical tab VT
\f formfeed FF
(.,.)ma The m (move) command repositions the addressed lines after the line addressed by a.
Address 0 is legal for a, causing the addressed lines to be moved to the beginning of the file.
It is an error if address a falls within the range of moved lines; Upon completion, the new
current line is the last line moved.
(
.,.)n The n (number) command prints the addressed lines, preceding each line by its line number
and a tab character. Upon completion, the new current line is the last line printed. The
n
command can be appended to any command other than e, f, r,or
w.
(
.,.)p The p (print) command prints the addressed lines. Upon completion, the new current line
is the last line printed. The p command may be appended to any other command other
than e, E, f, q, Q, r, w,or!
. For example, dp deletes the current line and prints the new
current line.
P The P (prompt) command causes ed to prompt with an asterisk (*) (or with string if the
-p
option was specified in the command line) for all subsequent commands. The P command
alternately turns this mode on and off. It is initially on if the
-p option was specified; oth-
erwise, off. The current line number is unchanged.
q The q (quit) command causes ed to exit. No automatic write of a file is done (but see
DIAGNOSTICS below).
Q The editor exits unconditionally without checking for changes in the buffer since the last
w
command.
($)r file The r (read) command reads the specified file into the buffer after the addressed line. If no
file name is given, the remembered file name, if any, is used (see the
e
and f commands).
The remembered file name is not changed unless file is the very first file name mentioned
since
ed was invoked. Address 0 is legal for r and places the contents of file at the begin-
ning of the buffer. If the read is successful, the number of characters read is displayed.
Upon completion, the new current line is the last line read into the buffer. If the file name
starts with
!, the rest of the line is interpreted as a shell command whose standard output
is to be read. For example, $r !ls appends a listing of files in the current directory to
the end of the file being edited. A shell command is not remembered as the current file
name.
(.,.)s/RE/replacement/flags
The s (substitute) command searches each addressed line for an occurrence of the specified
RE. In each line in which a match is found, all (nonoverlapped) matched strings are
replaced by replacement if the global replacement indicator g appears after the command.
If the global indicator does not appear, only the first occurrence of the matched string is
replaced. If a number n appears after the command, only the nth occurrence of the
matched string on each addressed line is replaced. It is an error for the substitution to fail
on all addressed lines. Any character other than space or newline can be used instead of /
to delimit the RE and replacement. Upon completion, the new current line is the last line
on which a substitution occurred. (Also see WARNINGS 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 preced-
ing 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.
Section 1−−206 Hewlett-Packard Company − 4 − HP-UX 11i Version 1: September 2005