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)  | barFor 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.
How can I redirect `time` output and command output to the same pipe?
shell;command line;pipe;time utility
If I understand what you're asking for I this will do. I'm using the commands ls ~ and tee as stand-ins for ./foo and bar, but the general form of what you want is this:$ ( time ./foo ) |& barNOTE: The output of time is already being attached at the end of any output from ./foo, it's just being done so on STDERR. To redirect it through the pipe you need to combine STDERR with STDOUT. You can use either |& or 2>&1 to do so.$ ( time ./foo ) |& bar-or-$ ( time ./foo ) 2>&1 | barExample$ ( time ls . ) |&  tee cmd.logcmd.logfile1file2file3file4file5real    0m0.005suser    0m0.000ssys     0m0.001sAnd here's the contents of the file cmd.log produced by tee.$ more cmd.log cmd.logfile1file2file3file4file5real    0m0.005suser    0m0.000ssys     0m0.001s