Displaying and changing the current line – HP NonStop G-Series User Manual

Page 170

Advertising
background image

then renumbers all the lines in the buffer. If you do not use a line number, the r subcommand adds
the new file to the end of the buffer’s contents.
The following example shows how to use the r subcommand with a line number:

1,$p
The only way to stop
appending is to type a
line that contains only
a period.
3r cfile
44
1,$p
The only way to stop
appending is to type a
line that contains only
The only way to stop
appending is to type
a period.

The 1,$p subcommand displays the four lines of afile. Next, the 3r cfile subcommand loads
the contents of cfile into the buffer, following line 3, and shows that it read 44 characters into
the buffer. The next 1,$p subcommand displays the buffer’s contents again, letting you verify that
the r subcommand read cfile into the buffer after line 3.
If you are working these examples on your system, do the following before you go to the next
subsection:
1.

Save the contents of the buffer in the file cfile:

w cfile

2.

Load afile into the buffer:

e afile

Displaying and Changing the Current Line

The ed program is a line editor. This means that ed lets you work with the contents of the buffer
one line at a time. The line you can work with at any given time is called the “current line,” and
it is represented by the period ( . ). To work with different parts of a file, you must change the
current line.
To display the current line, enter:

p

To display the line number of the current line, enter:

.=

NOTE:

You cannot use up arrow (¦) and down arrow (Ø) keys to change the current line. To

change the current line, use the ed subcommands described in the following subsections.

To change your position in the buffer, do one of the following:

To set your current line to line number n, enter:

n

To move the current line forward through the buffer one line at a time, press Return.

To move the current line backward through the buffer one line at a time, enter a hyphen (-).

To move the current line n lines forward through the buffer, enter:

+n

To move the current line n lines backward through the buffer, enter:

-n

170

The ed Editor

Advertising
This manual is related to the following products: