Date:        Tue, 11 Jun 2024 14:41:21 +0100
    From:        Ralph Corderoy <[email protected]>
    Message-ID:  <[email protected]>

  | 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.

The = command with no address prints the number of lines in the file,
which in your case happened to be 3 (that line 3 contained x was a
coincidence).

        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.)

kre



Reply via email to