title: Using awk to append columns on a file
body: <p>I have columns of data arriving from standard output (in my case a call to mysql), and I  would like to append at each loop the column in a file. How can I do?</p>
  
  <pre><code>Standard output:
  
   a1
   a2
  ....
   an
  </code></pre>
  
  <p>Saving in a file called table.dat:</p>
  
  <pre><code>table.dat:
  
   a1
   a2
  ....
   an
  </code></pre>
  
  <p>Then another output is produced:</p>
  
  <pre><code>Further standard output:
  
   b1
   b2
  ....
   bn
  </code></pre>
  
  <p>Appending to table.dat:</p>
  
  <pre><code>table.dat:
  
   a1   b1
   a2   b2
  .... ....
   an   bn
  </code></pre>
  
  <p>...and so on. I can use paste, but I need three steps:</p>
  
  <pre><code> line producing standard output &gt; tmpfile;
   paste prevfile tmpfile &gt; table
   mv table prevfile;
  </code></pre>
  
  <p>Is there a faster way, maybe by using awk?</p>
  
  <p>This solution:
  <a href="https://stackoverflow.com/questions/7551991/add-a-new-column-to-the-file">Add a new column to the file</a>
  produces an empty table.</p>