I currently want to run in my terminal cmd1 and cmd2. I want to pipe these outputs to cmd3, which can take multiple inputs.
I tried
cmd1 && cmd2 | cmd3 -i - -i -
But this does not accomplish what I'm trying to do
I currently want to run in my terminal cmd1 and cmd2. I want to pipe these outputs to cmd3, which can take multiple inputs.
I tried
cmd1 && cmd2 | cmd3 -i - -i -
But this does not accomplish what I'm trying to do
To answer your question literally ("Run two commands at same time and pipe to third command ")
You would need to put at least one of the LHS commands into the shell background using
&
, and group them so that the combined standard output may be redirected ex.Note that
&
is different from&&
(which waits forcmd1
to exit, then conditionally executescmd2
).You could replace the command group
{ ... ; }
with a subshell( ... )
if you prefer. Since the shell has only one standard output and one standard input stream, this will merge the outputs ofcmd1
andcmd2
To answer what you actually seem to want
To redirect the outputs of two separate commands as two separate input streams in bash, you can use process substitution: