title: How to redirect stdout+stderr to one file while keeping streams separate?
body: <p>Redirecting stdout+stderr such that both get written to a file while still outputting to stdout is simple enough:</p>
  
  <pre><code>cmd 2&gt;&amp;1 | tee output_file
  </code></pre>
  
  <p>But then now both stdout/stderr from cmd are coming on stdout. I'd like to write stdout+stderr to the same file (so ordering is preserved assuming cmd is single threaded) but then still be able to also separately redirect them, something like this:</p>
  
  <pre><code>some_magic_tee_variant combined_output cmd &gt; &gt;(command-expecting-stdout) 2&gt; &gt;(command-expecting-stderr)
  </code></pre>
  
  <p>So combined_output contains the both with order preserved, but the command-expecting-stdout only gets stdout and command-expecting-stderr only gets stderr. Basically, I want to log stdout+stderr while still allowing stdout and stderr to be separately redirected and piped. The problem with the tee approach is it globs them together. Is there a way to do this in bash/zsh?</p>