Hi kre,
Thanks for setting me straight.
> > I'm puzzled why g/x/= prints 3 twice rather than 1, 3.
>
> Add an extra line at the end (not containing x) and you'll see it
> prints 4 4, which makes what happened obvious.
I realised = was doing its normal thing of the number of lines in the
file because its address defaulted to $; I should have given a better
example, sorry.
> g/x/.=
>
> would do what you intended. (Most commands that you'd use with a g//
> prefix default to '.' if no address is given, '=' happens to be one
> which doesn't.)
Yes. Before writing, I checked various documents and saw ($)= and
already knew the default address was the last line of the file. I leapt
from ed(1p)'s description of g,
Then, going sequentially from the beginning of the file to the end
of the file, the given command list shall be executed for each
marked line, with the current line number set to the address of that
line.
to thinking that ‘the current line set’ would override the $ default.
Wrong, of course. ‘.’ is being set to each matching line which is
different to ‘.’ being implicitly given as an address to what
g executes.
Thanks again.
--
Cheers, Ralph.