3.3

Table Of Contents
F The Line Editor, ed
296
c
The Change command replaces the entire contents of the line addressed. For
instance:
21
terminal 13 9600-8n 1 news - ;
c
; not used
.
In the above example, the user selects line 21, and ed responds by displaying line
21. The user types c on one line to start the change operation. On the second line,
the user types replacement text and presses Enter, followed by a period on a line
by itself. The period (.) is very important because it terminates the change
operation. Without it, successive lines typed by the user would be added to the
file.
d
The Delete command is used to delete the line(s) specified. For instance:
27d
- Deletes line 27.
30,35d
- Deletes lines 30 through 35.
40,$d
- Deletes every line from 40 to the end of the file.
n
After each Delete command, as well as after the Append, Change, and
Insert commands, the file’s lines are renumbered. For instance, if you
delete line 27, then delete line 30, you actually delete the lines originally
numbered 27 and 31 prior to the first Delete command.
g
The Global command allows the user to apply an editing command to all lines in
the file that contain a specific word, phrase, or number. For instance:
g/asws/s/asws/inws
- Finds all occurrences of asws and uses the Substitute
command to replace the first occurrence of asws on each line found with inws.
To replace all occurences on a line, add /g to the end of the command, such as:
g/asws/s/asws/inws/g
g/websession/d
- Finds all occurrences of websession and deletes the lines
containing it.
Each line affected is displayed after the editing command is applied.
Command Description & Examples (Continued)