Line addressing
When a file is first read, the current address is
set to the address of the last line of the file.
Represent line numbers is the address ‘0’ (zero).
This means “at the beginning of the buffer”.
An address range is two addresses separated either
by a comma (’,’) or a semicolon (’;’).
A line address is constructed as follows
.
The current line (address) in the buffer.
$
The last line in the buffer.
n
The nth line in the buffer, where n is a number in
the range ‘0,$‘.
+n
The nth next line, where n is a non-negative
number.
-n
The nth previous line, where n is a non-negative
number.
+
The next line. This is equivalent to ‘+1’ and may
be repeated with cumulative effect.
-
The previous line. This is equivalent to ‘-1’ and
may be repeated with cumulative effect.
,
The first through last lines in the buffer. This
is equivalent to the address range ‘1,$‘.
;
The current through last lines in the buffer. This
is equivalent to the address range ’.;$‘.
/re/[I]
The next line containing the regular expression
re. The search wraps to the beginning of the
buffer and continues down to the current line, if
necessary. The suffix ‘I’ is a GNU extension which
makes ed match re in a case-insensitive manner.
?re?[I]
The previous line containing the regular
expression re. The search wraps to the end of the
buffer and continues up to the current line, if
necessary. The suffix ‘I’ is a GNU extension which
makes ed match re in a case-insensitive manner.