MPE/iX Shell and Utilities Reference Manual, Vol 1

ed(1) MPE/iX Shell and Utilities ed(1)
You can construct each address out of the following components:
. The single dot character represents the current line number. Many commands set
the current line number. For example, the e command sets it to the last line of the
new file being edited.
$ The dollar sign refers to the last line in the buffer.
n The number n refers to the nth line in the buffer.
/regexp/ This searches for a line containing a string that matches the basic regular expres-
sion regexp (see regexp(3)). The search begins at the line immediately follow-
ing the current line. It proceeds forward through the buffer; if ed reaches the end
of the buffer without finding a match, it wraps around to the first line of the buffer
and continues the search. If ed does not find a match, the search ends when it
reaches the original current line. If it finds a match, the address /regexp/ refers to
the first matching line. If you omit regexp, the last used regular expression
becomes the object of the search. You can omit the trailing /. Within regexp, \/
represents a literal slash and not the regexp delimiter.
?regexp? This similar to the previous address form, except that the search goes backward
through the buffer. If the search reaches the first line in the buffer without finding
a match, ed wraps around and continues searching backward from the last line in
the buffer. If you omit regexp, the last used regular expression becomes the
object of the search. You can omit the trailing ?. Within regexp, \? represents a
literal question mark and not the regexp delimiter.
´l The address is the line marked with the mark name l. The name l must be a lower-
case letter set by the k command.
You can combine these basic addresses with numbers using the + and operators, with the
usual interpretation. Missing left operands default to . (dot); missing right operands default
to 1. Missing right operands also have a cumulative effect; so an address of -- refers to the
current line number less 2.
You can specify address ranges in the following ways:
a1, a2 specifies a range of addresses from address a1 to address a2, inclusive. Omitting
a1 and a2 (that is, specifying only the comma), is equivalent to the range 1,$.
a1; a2 is similar to the previous form except that ed resets the current line number after
calculating a1, so that the second address, a2, is relative to a1. Omitting a1 and
a2 (that is, specifying only the semicolon), is equivalent to .;$.
1-196 Commands and Utilities