title: Add Column to end of CSV file using 'awk' in BASH script
body: <p>How do you add a column to the end of a CSV file with using a string in a variable?</p>
  <h3>input.csv</h3>
  <pre><code>2012-02-29,01:00:00,Manhattan,New York,234
  2012-02-29,01:00:00,Manhattan,New York,843
  2012-02-29,01:00:00,Manhattan,New York,472
  2012-02-29,01:00:00,Manhattan,New York,516
  </code></pre>
  <h3>output.csv</h3>
  <pre><code>2012-02-29,01:00:00,Manhattan,New York,234,2012-02-29 16:13:00
  2012-02-29,01:00:00,Manhattan,New York,843,2012-02-29 16:13:00
  2012-02-29,01:00:00,Manhattan,New York,472,2012-02-29 16:13:00
  2012-02-29,01:00:00,Manhattan,New York,516,2012-02-29 16:13:00
  </code></pre>
  <h3>awk.sh</h3>
  <pre><code>#!/bin/bash
  
  awk -F&quot;,&quot; '{$6=&quot;2012-02-29 16:13:00&quot; OFS $6; print}' input.csv &gt; output.csv
  </code></pre>
  <p>My attempt above in <strong>awk.sh</strong> added the string to the end but stripped all the comma separators.</p>
  <h3>awk.sh result</h3>
  <pre><code>2012-02-29 01:00:00 Manhattan New York 234 2012-02-29 16:13:00
  2012-02-29 01:00:00 Manhattan New York 843 2012-02-29 16:13:00
  2012-02-29 01:00:00 Manhattan New York 472 2012-02-29 16:13:00
  2012-02-29 01:00:00 Manhattan New York 516 2012-02-29 16:13:00
  </code></pre>
  <p>Appreciate any help!</p>
  <h3>Updated awk.sh</h3>
  <pre><code>#!/bin/bash
  
  GAWK=&quot;/bin/gawk&quot;
  TIMESTAMP=$(date +&quot;%F %T&quot;)
  ORIG_FILE=&quot;input.csv&quot;
  NEW_FILE=&quot;output.csv&quot;
  
  #Append 'Create' DateTimeStamp to CSV for MySQL logging
  $GAWK -v d=&quot;$TIMESTAMP&quot; -F&quot;,&quot; 'BEGIN {OFS = &quot;,&quot;} {$6=d; print}' $ORIG_FILE &gt; $NEW_FILE
  rm -f $ORIG_FILE
  </code></pre>