ekiim
ekiim

Reputation: 842

Catching STDOUT and STDERR with pipes on next command as separated arguments?

Is it possible to have a command to catch both STDOUT and STDERR as separated streams to use as arguments in the next command?

An example of it would be.

# foo outputs to stdout and stderr
# bar recieves in -i and -j streams that could be files but in general they are streams, so it would make sence to pipe to any of this two. 
$ foo | bar -i - -j -&2 

Can I do this in bash? or in some other shell?

Upvotes: 0

Views: 48

Answers (1)

You can do this with the help of named pipes:

mkfifo /tmp/whatever
foo 2>/tmp/whatever | bar -i - -j /tmp/whatever

No data actually gets written to /tmp/whatever. The kernel sends the writing process's output straight to the reading process.

Upvotes: 3

Related Questions