3.3

Table Of Contents
Starting ed
297
i
The Insert command inserts one or more lines before the selected line. For
instance:
/websession/
;websession 900
i
inws 511 - gnews - ;
inws
.
In the above example, the user searches for websession, and ed responds by
displaying the first line found containing that word. The user types i and presses
Enter to start the insert operation. The user then types two lines of information to
be inserted in the file before the displayed line. On the last line, the user types a
period (.) on a line by itself, which is very important because it terminates the
insert operation. Without it, successive lines typed by the user would be added to
the file.
m
The Move command removes the line(s) specified from their original location
and inserts the line(s) after the target location. For instance:
18m20
- Line 18 becomes line 20. Lines 19 and 20 become 18 and 19.
1,5m$
- Moves lines 1 through 5 to the end of the file.
p
Contrary to the name, the Print command does not send information to a printer.
Instead, it prints text to the console screen. It is handy for viewing specific lines
within a file. Typed alone with no line number references, the Print command
displays the current line.
For instance, to print (to screen) lines 10-20, type:
10,20p
.
More examples of the Print command can be found in “Specifying Lines to Edit”
on page 292.
s/<old text>/
<new text>
The Substitute command substitutes a specific portion of a line with new text.
For instance:
3
;AvidNews Starter config 09JAN10
s/AvidNews/iNEWS
;iNEWS Starter config 09JAN10
In the above example, the user selects line 3, and ed responds by displaying line
3. The user substitutes the word AvidNews for iNEWS but does not alter
anything else on the line. The line editor, ed, confirms the substitution by
redisplaying line 3, incorporating the change.
Command Description & Examples (Continued)