Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #236802

Re: Useless use of shell pipelines [was: Useful use of dd]

Path csiph.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!bofh.it!news.nic.it!robomod
From Greg Wooledge <greg@wooledge.org>
Newsgroups linux.debian.user
Subject Re: Useless use of shell pipelines [was: Useful use of dd]
Date Sat, 03 Jul 2021 15:40:01 +0200
Message-ID <CwO2d-4tb-3@gated-at.bofh.it> (permalink)
References <Cv0TT-1C0-3@gated-at.bofh.it> <Cv6cV-4QX-1@gated-at.bofh.it> <Cwhzj-715-1@gated-at.bofh.it> <CwilH-7y5-1@gated-at.bofh.it> <CwkdP-rs-3@gated-at.bofh.it> <Cwm5X-1xu-5@gated-at.bofh.it> <Cwz3c-135-5@gated-at.bofh.it> <CwJcd-1q2-1@gated-at.bofh.it>
X-Mailbox-Line From debian-user-request@lists.debian.org Sat Jul 3 13:34:27 2021
Old-Return-Path <greg@wooledge.org>
X-Amavis-Spam-Status No, score=-5.207 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, DIGITS_LETTERS=1, LDO_WHITELIST=-5, RDNS_NONE=0.793] autolearn=no autolearn_force=no
X-Policyd-Weight using cached result; rate: -4.6
Mail-Followup-To debian-user@lists.debian.org
MIME-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Disposition inline
Content-Transfer-Encoding 8bit
X-Mailing-List <debian-user@lists.debian.org> archive/latest/777410
List-ID <debian-user.lists.debian.org>
List-URL <https://lists.debian.org/debian-user/>
List-Archive https://lists.debian.org/msgid-search/YOBnUMNFekHhpq63@wooledge.org
Approved robomod@news.nic.it
Lines 31
Organization linux.* mail to news gateway
Sender robomod@news.nic.it
X-Original-Date Sat, 3 Jul 2021 09:34:08 -0400
X-Original-Message-ID <YOBnUMNFekHhpq63@wooledge.org>
X-Original-References <4ef539b6-af04-4d53-9512-cd3dba0d4ce3@gmx.com> <bb07defe-eaea-ddee-e534-73289541cc60@holgerdanske.com> <20210702025528.GA14316@axis.corp> <ea57b6a6-f3d2-d256-5ce3-94afdb34c833@holgerdanske.com> <87im1ts27c.fsf@iki.fi> <20210702074923.GA9613@tuxteam.de> <d3ef0534-3614-59a1-9575-25befbe7b31e@holgerdanske.com> <MdfSou2--3-2@tuta.io>
Xref csiph.com linux.debian.user:236802

Show key headers only | View raw


On Sat, Jul 03, 2021 at 10:23:39AM +0200, l0f4r0@tuta.io wrote:
> 2 juil. 2021, 23:30 de dpchrist@holgerdanske.com:
> > $ cat useless-use-of-grep
> > This is the first line: bla bla bla.
> > This is line xxxx: bla bla bla.
> > This is the last line: bla bla bla.

> Here is a better `sed` if you want a all-in-one: 
> sed -n /xxxx/{s/bla/foo/p} useless-use-of-grep

Also:
awk '/xxxx/{sub("bla", "foo"); print}' useless-use-of-grep

> > $ time for n in {1..10000}; do perl -ne 's/bla/foo/ && print if /xxxx/' useless-use-of-grep > /dev/null; done
> >
> > real	0m23.624s
> > user	0m14.308s
> > sys	0m10.826s

> I'm not in front of my Linux terminal, can someone launch the `time` command for my `sed` above please ? :)

unicorn:~$ time for n in {1..10000}; do perl -ne 's/bla/foo/ && print if /xxxx/' useless-use-of-grep; done >/dev/null
real 16.034  user 11.555  sys 4.847

unicorn:~$ time for n in {1..10000}; do sed -n '/xxxx/{s/bla/foo/p}' useless-use-of-grep; done >/dev/null
real 11.489  user 8.670  sys 3.251

unicorn:~$ time for n in {1..10000}; do awk '/xxxx/{sub("bla", "foo"); print}' useless-use-of-grep; done >/dev/null
real 15.690  user 11.575  sys 4.532

Sed wins this particular race, not surprisingly.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Whole Disk Encryption + SSD piorunz <piorunz@gmx.com> - 2021-06-28 17:00 +0200
  Re: Whole Disk Encryption + SSD Jochen Spieker <ml@well-adjusted.de> - 2021-06-28 18:00 +0200
  Re: Whole Disk Encryption + SSD David Christensen <dpchrist@holgerdanske.com> - 2021-06-28 22:40 +0200
    Re: Whole Disk Encryption + SSD David Christensen <dpchrist@holgerdanske.com> - 2021-06-29 00:00 +0200
    Re: Whole Disk Encryption + SSD Stefan Monnier <monnier@iro.umontreal.ca> - 2021-06-29 02:00 +0200
      Re: Whole Disk Encryption + SSD <tomas@tuxteam.de> - 2021-06-29 09:50 +0200
        Re: Whole Disk Encryption + SSD Stefan Monnier <monnier@iro.umontreal.ca> - 2021-06-30 00:50 +0200
        Re: Whole Disk Encryption + SSD David Christensen <dpchrist@holgerdanske.com> - 2021-06-30 01:00 +0200
    Re: Whole Disk Encryption + SSD Jonathan Dowland <jon+debian-user@dow.land> - 2021-06-29 11:30 +0200
    Re: Whole Disk Encryption + SSD piorunz <piorunz@gmx.com> - 2021-06-29 14:10 +0200
      Re: Whole Disk Encryption + SSD David Christensen <dpchrist@holgerdanske.com> - 2021-06-30 02:20 +0200
    Re: Whole Disk Encryption + SSD David Wright <deblis@lionunicorn.co.uk> - 2021-07-02 05:00 +0200
      Re: Whole Disk Encryption + SSD David Christensen <dpchrist@holgerdanske.com> - 2021-07-02 05:50 +0200
        Useless use of "dd" Teemu Likonen <tlikonen@iki.fi> - 2021-07-02 07:50 +0200
          Useful use of dd [was: Useless use of "dd"] <tomas@tuxteam.de> - 2021-07-02 09:50 +0200
            Re: Useful use of dd [was: Useless use of "dd"] Teemu Likonen <tlikonen@iki.fi> - 2021-07-02 12:30 +0200
              Re: Useful use of dd "Thomas Schmitt" <scdbackup@gmx.net> - 2021-07-02 13:00 +0200
                Re: Useful use of dd <tomas@tuxteam.de> - 2021-07-02 13:20 +0200
                Re: Useful use of dd Teemu Likonen <tlikonen@iki.fi> - 2021-07-02 13:30 +0200
                Re: Useful use of dd David Christensen <dpchrist@holgerdanske.com> - 2021-07-02 23:50 +0200
              Re: Useful use of dd [was: Useless use of "dd"] <tomas@tuxteam.de> - 2021-07-02 13:20 +0200
              Re: Useful use of dd Michael Stone <mstone@debian.org> - 2021-07-02 14:50 +0200
              Re: Useful use of dd [was: Useless use of "dd"] Kushal Kumaran <kushal@locationd.net> - 2021-07-02 21:10 +0200
                Creation of empty files [was: Useful use of dd] David Christensen <dpchrist@holgerdanske.com> - 2021-07-02 23:40 +0200
                Re: Creation of empty files [was: Useful use of dd] David Christensen <dpchrist@holgerdanske.com> - 2021-07-03 00:00 +0200
                Re: Creation of empty files [was: Useful use of dd] Michael Stone <mstone@debian.org> - 2021-07-03 15:50 +0200
                Re: Creation of empty files [was: Useful use of dd] David Christensen <dpchrist@holgerdanske.com> - 2021-07-03 23:40 +0200
                Re: Creation of empty files [was: Useful use of dd] Michael Stone <mstone@debian.org> - 2021-07-04 06:00 +0200
            Re: Useful use of dd [was: Useless use of "dd"] Greg Wooledge <greg@wooledge.org> - 2021-07-02 13:40 +0200
              Re: Useful use of dd [was: Useless use of "dd"] <tomas@tuxteam.de> - 2021-07-02 13:40 +0200
                Re: Useful use of dd [was: Useless use of "dd"] David Wright <deblis@lionunicorn.co.uk> - 2021-07-02 17:10 +0200
                Re: Useful use of dd [was: Useless use of "dd"] <tomas@tuxteam.de> - 2021-07-02 17:40 +0200
                Re: Useful use of dd [was: Useless use of "dd"] Gunnar Gervin <dofeelok@gmail.com> - 2021-07-03 09:20 +0200
                Re: Useful use of dd [was: Useless use of "dd"] <tomas@tuxteam.de> - 2021-07-03 09:30 +0200
            Useless use of shell pipelines [was: Useful use of dd] David Christensen <dpchrist@holgerdanske.com> - 2021-07-02 23:40 +0200
              Re: Useless use of shell pipelines [was: Useful use of dd] l0f4r0@tuta.io - 2021-07-03 10:30 +0200
                Re: Useless use of shell pipelines [was: Useful use of dd] Greg Wooledge <greg@wooledge.org> - 2021-07-03 15:40 +0200
          Re: Useless use of "dd" David Christensen <dpchrist@holgerdanske.com> - 2021-07-02 21:40 +0200
        Re: Whole Disk Encryption + SSD David Wright <deblis@lionunicorn.co.uk> - 2021-07-02 17:10 +0200
          Re: Whole Disk Encryption + SSD Michael Stone <mstone@debian.org> - 2021-07-02 17:30 +0200
          Re: Whole Disk Encryption + SSD David Christensen <dpchrist@holgerdanske.com> - 2021-07-02 20:40 +0200

csiph-web