On 04/09/2021, Parodper <parod...@gmail.com> wrote:
> I think I found something. From POSIX
> (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html):
>  > A line can be split by substituting a <newline> into it. The
>  > application shall escape the <newline> in the replacement by preceding
>  > it by a <backslash>.

Are you or is anyone clear on what they mean by substituting?  Because
I'm not.  I mean, \n is a substitute for the literal <newline>
character, right?

> So I wrote
> :!sed s/abc/abc\/g % | grep -c abc
> and then went back and pressed <ENTER> after that backslash, i.e.
> :!sed s/abc/abc\<ENTER>/g % | grep -c abc
> And it gave me a correct number of abc's for my test text.

I feel like the dumbest person in the world asking this, but what
EXACTLY do you mean by "and then went back"?
Are you using cursor keys?  I.e. should I have gotten those to work in
vi in  xterm and console?  Because I haven't.  The moment I try to
cursor back, I'm back to vi mode and the ex-style command mode line at
the bottom is gone.

Otherwise, if I try to just type
  :!sed s/abc/abc\/g % | grep -c abc
and press enter, I only get the same output I also get out of
  :!grep -c abc %
on its own -- which won't count multiple same-line occurrences.

A still confused
Ian

Reply via email to