title: Redirecting C++ generated cerr and cout to the same file in Ubuntu
body: <p>My program generates output both directed to std::cout and std::cerr. When I run a test file normally as in</p>
  
  <pre><code>./a.out &lt;source&gt; &amp;&gt; &lt;target&gt;  
  </code></pre>
  
  <p>target captures both types of output in the order produced by ./a.out.  </p>
  
  <p>When trying to automate testing of output for a simple unit testing framework, I implemented the above in a bash script:   </p>
  
  <pre><code> `rm $OUT_NAME`
   `./a.out $NEW_UNIT &amp;&gt; $OUT_NAME`   
  </code></pre>
  
  <p>(with the obvious variable names). The output sent to cout is printed fine; but the one sent to cerr is printed incorrectly (some is printed; then printing stops with no error). In case you wonder, I added the 'rm' first just to be perfectly sure it's no issue with over-writing/appending to an old version.</p>
  
  <p>Any ideas?</p>
  
  <p>My system:
  Ubuntu 12.04.</p>