The key to making line editors work for you is understanding how to
select (or "address") the lines that will be affected by the commands in your
script.

In
ed
and
ex
, a command affects only the "current" line - the
first line of the file to begin with, and later the site of the last
edit or movement command - unless you precede the command with
an address to indicate some other line or lines. In
sed
, most
commands apply to every line unless you give an address.