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 $. An l (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 ®le. |
| 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. |
PThe P (prompt) command causes ed to prompt with an asterisk (*) (or with string if the
qThe q (quit) command causes ed to exit. No automatic write of a ®le is done (but see DIAGNOSTICS below).
QThe editor exits unconditionally without checking for changes in the buffer since the last w command.
($)r file The r (read) command reads the speci®ed ®le into the buffer after the addressed line. If no ®le name is given, the remembered ®le name, if any, is used (see the e and f commands). The remembered ®le name is not changed unless ®le is the very ®rst ®le name mentioned since ed was invoked. Address 0 is legal for r and places the contents of ®le at the beginning 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 ®le 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 ®les in the current directory to the end of the ®le being edited. A shell command is not remembered as the current ®le name.
(.,.)s/RE/replacement/flags
The s (substitute) command searches each addressed line for an occurrence of the speci®ed 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 ®rst 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 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 speci®ed RE enclosed between \( and \). When nested parenthesized subexpressions are present, n is determined by counting occurrences of \(, starting from the left.
Section 1−198 | − 4 − |