help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] silly question - which is better to pipe 2 sources into


From: John McKown
Subject: Re: [Help-bash] silly question - which is better to pipe 2 sources into one command
Date: Mon, 30 Apr 2018 09:40:05 -0500

On Mon, Apr 30, 2018 at 9:22 AM, Greg Wooledge <address@hidden> wrote:

> On Mon, Apr 30, 2018 at 09:10:41AM -0500, John McKown wrote:
> > Way one:  { pgm1; pgm2; } | pgm3
> > Way two: cat <(pgm1) <(pgm2) | pgm3
> >
> > Way one _seems_ better to me mainly because there are fewer processes
> > running.
>
> Agreed.  That is what I'd use.
>
> > But I'm wondering a bit about way two. I don't know really how that is
> > working. I think that "pgm1" and "pgm2" are both fork()'d & exec()'d to
> run
> > concurrently.
>
> But cat reads all of the first input (until EOF), before starting to read
> the second input.  So the second process is simply blocked until cat is
> ready to read from it.
>
> It's still the more complex (therefore worse) choice.
>
​
​That's what I was thinking, but I wanted some reinforcement that I was
thinking correctly. Another plus is that I think way one will work in other
Bourne-like shells since they don't all have BASH's process substitution.​




-- 
We all have skeletons in our closet.
Mine are so old, they have osteoporosis.

Maranatha! <><
John McKown


reply via email to

[Prev in Thread] Current Thread [Next in Thread]