3.3

Table Of Contents
F The Line Editor, ed
292
Starting ed
When you modify a file, make the same changes to each server’s copy of the file, or your
system will not run properly. Select all servers before starting ed and opening a file for
editing to ensure changes you make are applied to each server’s copy of the file.
To start ed from the console:
t Type ed followed by the file path and name to be edited. For instance, to edit a copy of
the configuration file in the Site directory, you would type:
NRCS-A
$ ed /site/config.test
3624
The line editor, ed, returns a number indicating the file size expressed as the number of
characters, including spaces and returns. Also, the console prompt, NRCS-A$, changes
to no prompt when you launch the editor.
If the file name specified does not exist or is a non-text file unsuitable for editing with
ed, ed returns a question mark (?) followed by the file name. This is one way to create a
new text file. For instance, a new text file called newfile is created when the following is
typed:
NRCS-A
$ ed newfile
?newfile
c
Do not attempt to edit a non-text file such as a binary file. Doing so could cause
undesirable results.
Specifying Lines to Edit
The line you are on presently is called the current line.
Because ed is a line editor, you navigate through the file by line numbers. For instance, when
you open a file for editing, ed considers the last line in the file the current line. If you want to
view or edit a different line, you must go to that line.
For instance, you can move to the first line of the file by typing
1
and pressing Enter. To
move ahead five lines, you could type
+5
. To move back three lines, you could type
-3
.
n
The line editor, ed, will respond with a question mark (?) if you try to move beyond the last
line of the file. Additionally, you cannot type a minus (-) value greater than or equal to the
current line number, because you cannot move to a line preceding the first line in the file.