|
|
coherent
ed Command ed
Interactive line editor
eedd [-] [+ccmmooppssvv] [_f_i_l_e]
ed is the COHERENT system's interactive line editor.
ed is a line-oriented interactive text editor. With it, you can
locate and replace text patterns, move or copy blocks of text,
and print parts of the text. ed can read text from input files
and can write all or part of the edited text to other files.
ed reads commands from the standard input, usually one command
per line. Normally, ed does not prompt for commands. If the
optional file argument is given, ed edits the given file, as if
the file were read with the e command described below.
ed manipulates a copy of the text in memory rather than with the
file itself. No changes to a file occur until the user writes
edited text with the w command. Large files can be divided with
split or edited with the stream editor sed.
ed remembers some information to simplify its commands. The cur-
rent line is typically the line most recently edited or printed.
When ed reads in a file, the last line read becomes the current
line. The current file name is the last file name specified in
an e or f command. The current search pattern is the last pat-
tern specified in a search specification.
ed identifies text lines by integer line numbers, beginning with
one for the first line. Several special forms identify a line or
a range of lines, as follows:
_n A decimal number n specifies the nth line of the text.
. A period `.' specifies the current line.
$ A dollar sign `$' specifies the last line of the text.
+,- Simple arithmetic may be performed on line numbers.
/_p_a_t_t_e_r_n/
Search forward from the current line for the next occurrence
of the pattern. If ed finds no occurrence before the end of
the text, the search wraps to the beginning of the text.
Patterns, also called regular expressions, are described in
detail below.
?_p_a_t_t_e_r_n?
Search backwards from the current line to the previous oc-
currence of the pattern. If ed finds no occurrence before
the beginning of the text, the search wraps to the end of
the text.
COHERENT Lexicon Page 1
ed Command ed
'_x Lines marked with the kx command described below are iden-
tified by 'x. The x may be any lower-case letter.
_n,_m Line specifiers separated by a comma `,' specify the range
of lines between the two given lines, inclusive.
_n;_m Line specifiers separated by a semicolon `;' specify the
range of lines between the two given lines, inclusive. Nor-
mally, ed updates the current line after it executes each
command. If a semicolon `;' rather than a comma separates
two line specifiers, ed updates the current line before
reading the second.
* An asterisk `*' specifies all lines; it is equivalent to
1,$.
***** Commands *****
ed commands consist of a single letter, which may be preceded by
one or two specifiers that give the line or lines to which the
command is to be applied. The following command summary uses the
notations [_n] and [_n[,_m]] to refer to an optional line specifier
and an optional range, respectively. These default to the cur-
rent line when omitted, except where otherwise noted. A semi-
colon `;' may be used instead of a comma `,' to separate two line
specifiers.
. Print the current line. Also, a line containing only a
period `.' marks the end of appended, changed, or inserted
text.
[_n] Print given line. If no line number is given (i.e., the
command line consists only of a newline character), print
the line that follows the current line.
[_n]= Print the specified line number (default: last line number).
[_n]& Print a screen of 23 lines; equivalent to _n,_n+2222pp.
! _l_i_n_e
Pass the given line to the shell sh for execution. ed
prompts with an exclamation point `!' when execution is com-
pleted.
? Print a brief description of the most recent error.
[_n]aa Append new text after line n. Terminate new text with line
that contains only a period `.'.
[_n[,_m]]cc
Change specified lines to new text. Terminate new text with
a line that contains only a period `.'.
[_n[,_m]]dd[pp]
Delete specified lines. If p follows, print new current
COHERENT Lexicon Page 2
ed Command ed
line.
ee [_f_i_l_e]
Edit the specified file (default: current file name). An
error occurs if there are unsaved changes. Reissuing the
command after the error message forces ed to edit the file.
EE [_f_i_l_e]
Edit the specified file (default: current file name). No
error occurs if there are unsaved changes.
ff [_f_i_l_e]
Change the current file name to file and print it. If file
is omitted, print the current file name.
[_n[,_m]]gg/[_p_a_t_t_e_r_n]/_c_o_m_m_a_n_d_s
Globally execute commands for each line in the specified
range (default: all lines) that contains the pattern
(default: current search pattern). The commands may extend
over several lines, with all but the last terminated by `\'.
[_n]ii Insert text before line n. Terminate new text with a line
that contains only a period `.'.
[_n[,_m]]jj[pp]
Join specified lines into one line. If m is not specified,
use range n, If no range is specified, join the current line
with the next line. With optional p, print resulting line.
[_n]kk_x
Mark given line with lower-case letter x.
[_n[,_m]]ll
List selected lines, interpreting non-graphic characters.
[_n[,_m]]mm[_d]
Move selected lines to follow line d (default: current
line).
oo _o_p_t_i_o_n_s
Change the given options. The options may consist of an
optional sign `+' or `-', followed by one or more of the
letters `ccmmooppssvv'. Options are explained below.
[_n[,_m]][pp]
Print selected lines. The p is optional.
qq Quit editing and exit. An error occurs if there are unsaved
changes. Reissuing the command after the error message for-
ces ed to exit.
QQ Quit editing and exit. No error occurs if there are unsaved
changes.
COHERENT Lexicon Page 3
ed Command ed
[_n]rr [_f_i_l_e]
Read file into current text after given line (default: last
line).
[_n[,_m]]ss[_k]/[_p_a_t_t_e_r_n_1]/_p_a_t_t_e_r_n_2/[gg][pp]
Search for pattern1 (default, remembered search pattern) and
substitute pattern2 for kth occurrence (default, first) on
each line of the given range. If g follows, substitute
every occurrence on each line. If p follows, print the
resulting current line.
[_n[,_m]]tt[_d]
Transfer (copy) selected lines to follow line d (default,
current line).
[_n]uu[pp]
Undo effect of last substitute command. If optional p
specified, print undone line. The specified line must be
the last substituted line.
[_n[,_m]]vv/[_p_a_t_t_e_r_n]/_c_o_m_m_a_n_d_s
Globally execute commands for each line in the specified
range (default: all lines) not containing the pattern
(default: current search pattern). The commands may extend
over several lines, with all but the last terminated by `\'.
The v command is like the g command, except the sense of the
search is reversed.
[_n[,_m]]ww [_f_i_l_e]
Write selected lines (default, all lines) to file (default,
current file name). The previous contents of file, if any,
are lost.
[_n[,_m]]WW [_f_i_l_e]
Write specified lines (default, all lines) to the end of
file (default, current file name). Like w, but appends to
file instead of truncating it.
***** Patterns *****
Substitution commands and search specifications may include pat-
terns, also called regular expressions. A non-special character
in a pattern matches itself. Special characters include the
following.
^ Match beginning of line, unless it appears immediately after
`[' (see below).
$ Match end of line.
* Matches zero or more repetitions of preceding character.
. Matches any character except newline.
COHERENT Lexicon Page 4
ed Command ed
[_c_h_a_r_s]
Matches any one of the enclosed chars. Ranges of letters or
digits may be indicated using `-'.
[^_c_h_a_r_s]
Matches any character except one of the enclosed chars.
Ranges of letters or digits may be indicated using `-'.
\_c Disregard special meaning of character c.
\(_p_a_t_t_e_r_n\)
Delimit substring pattern for use with \_d, described below.
The replacement part pattern2 of the substitute command may also
use the following:
& Insert characters matched by pattern1.
\_d Insert substring delimited by dth occurrence of delimiters
`\(' and `\)', where d is a digit.
***** Options *****
The user may specify ed options on the command line, in the en-
vironment, or with the o command. The available options are as
follows:
cc Print character counts on e, r, and w commands.
mm Allow multiple commands per line.
oo Print line counts instead of character counts on e, r, and w
commands.
pp Prompt with an `*' for each command.
ss Match lower-case letters in a pattern to both upper-case and
lower-case text characters.
vv Print verbose versions of error messages.
The c option is normally set, and all others are normally reset.
Options may be set on the command line with a leading `+' sign.
The `-' command line option resets the c option.
Options may be set in the environment with an assignment, such as
export ED=+cv
Options may be set with the `+' prefix or reset with the `-'
prefix.
COHERENT Lexicon Page 5
ed Command ed
***** See Also *****
commands, me, sed
_I_n_t_r_o_d_u_c_t_i_o_n _t_o _e_d
***** Diagnostics *****
ed usually prints only the diagnostic `?' on any error. When the
verbose option v is specified, the `?' is followed by a brief
description of the nature of the error.
COHERENT Lexicon Page 6
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.