sed is so wonderfully versatile!
need to type up ``the rattlin bog'' as fast as it is sung?
do it in n ^ 0.5 time with
sed H\;g
slick as quick-silver!
On 04/09/2021, ropers wrote:
> On 04/09/2021, Marc Chantreux wrote:
>> Another solution is to write commands for this kind of tasks:
>>
>> <<\. cat > ~/x
>> #! /bin/ksh
>>
>> sed -r 's/a/&\
>> /g'
>> .
>
> Wait, hold up, I'm not familiar with this input redirection idiom.
> Could you explain? Wh
> Date: Sun, 5 Sep 2021 09:11:21 +1000
> From: Reuben ua Bríġ
> easy peasy. to sed all spaces into newlines
you might as well just
sed 'y/ /\n/'
the inverse is almost as easy
sed '1h;1!H;$!d;g;y/\n/ /'
im sure yoar kicking yourself for not seeing such a simple solution.
> Date: Sun, 5 Sep 2021 09:11:21 +1000
> From: Reuben ua Bríġ
> > Date: Sat, 4 Sep 2021 23:22:29 +0100
> > From: ropers
>
> > It's still a little disconcerting to me how getting sed to play nice
> > with \n *from inside vi* still seems like a bridge too far
>
> easy peasy. to sed all spa
> Date: Sat, 4 Sep 2021 23:22:29 +0100
> From: ropers
> It's still a little disconcerting to me how getting sed to play nice
> with \n *from inside vi* still seems like a bridge too far
easy peasy. to sed all spaces into newlines from nvi, enter
:!sed 's/ /&^V^M/g;y/^V^M/\n/'
echoed a
On 04/09/2021, Parodper wrote:
> O 04/09/21 ás 18:25, ropers escribiu:
>> On 04/09/2021, Parodper wrote:
>>> So I wrote
>>> :!sed s/abc/abc\/g % | grep -c abc
>>> and then went back and pressed after that backslash, i.e.
>>> :!sed s/abc/abc\/g % | grep -c abc
>>> And it gave me a correct number
On 04/09/2021, Marc Chantreux wrote:
> hello,
>
>> :!sed s/abc/abc\n/g % | grep -c abc
>
> Note: in sed, "what i just matched" is noted &
Oh, that's good, thank you.
*Shoulda seenit on the man page -- butta dinnt.*
>From sed(1):
> An ampersand (‘&’) appearing in the replacement is replaced
On Sat, Sep 04, 2021 at 05:00:29PM +0100, ropers wrote:
> However, that's as inaccurate as, or potentially even more inaccurate
> than your version, at least as far as vim-ilarity is concerned. My
> awk-ward incantation matches vim's :%s/abc//gn precisely.
Not sure if this is less "awk-ward":
:%
O 04/09/21 ás 18:25, ropers escribiu:
On 04/09/2021, Parodper wrote:
So I wrote
:!sed s/abc/abc\/g % | grep -c abc
and then went back and pressed after that backslash, i.e.
:!sed s/abc/abc\/g % | grep -c abc
And it gave me a correct number of abc's for my test text.
I feel like the dumbest p
> 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
same here! I so much wish it worked!
regards
marc
On 04/09/2021, Parodper 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 into it. The
> > application shall escape the in the replacement by preceding
> > it by a .
Are you or is
On 04/09/2021, Marc Chantreux wrote:
>
> :w !tr -cs '[:alnum:]' '\n'|grep -c abc
>
Is tr's -s option there to eliminate multiple newlines?
If so, is there harm in omitting it, since grep won't count those anyway?
:w !tr -c '[:alnum:]' '\n' | grep -c abc
I think your one-liner is not bad.
12 matches
Mail list logo