1

I would like to redirect the output of two programs to a single STDIN pipe, possibly in the most efficient way possible.

Is that possible?

cedivad
  • 2,544
  • 6
  • 32
  • 41

1 Answers1

5

Yes.

{ command1 ; command2 ; } | command3
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • So basically create a third program that has the first two running in background and redirects it's output. Makes a lot of sense, I should have thought of it. Thank you. – cedivad Nov 15 '14 at 17:14
  • Is it recognizable for `command3`? I mean what is order of piping. Is it a first and second scenario or they go through each other? – muradin Nov 15 '14 at 19:25
  • @muradin: The command grouping assures that `command1` and `command2` both use the same stdout. – Ignacio Vazquez-Abrams Nov 15 '14 at 19:53
  • @cedivad: Nothing is running in the background in Ignacio's answer. The braces `{` and `}` enclose a _group command_. See the bash man under `Compound Commands`. – PM 2Ring Nov 16 '14 at 10:20
  • Yes, I confused `;` with `&`. Replacing them did the trick anyway. It created another problem, and I ended up using a completely different solution, but did what was asked in the question. – cedivad Nov 17 '14 at 10:41