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: Greg Wooledge
Subject: Re: [Help-bash] silly question - which is better to pipe 2 sources into one command
Date: Mon, 30 Apr 2018 10:22:21 -0400
User-agent: NeoMutt/20170113 (1.7.2)

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.



reply via email to

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