Suppose I have a binary called foo
.
If I want to redirect the output of foo
to some other process bar
, I could write ./foo | bar
.
On the other hand, if I wanted to time
foo, and redirect the output of time
I could write, time (./foo) | bar
.
My question is, how can I stick the output of time
to the end of the output of foo
and pipe it through the same pipe?
The following solution is not what I am looking for, because it starts two separate instances of the process bar
, while I want a single shared pipe, to a single instance of bar
.
time (./foo | bar) | bar
For anyone who is curious, the reason for not wanting to start two instances of bar
is because bar
can be a network client and I want the timing information to be sent to the server as part of the same http POST
message as the process output.