title: Append Columns to CSV in For Loop
body: <p>I'm looking for some help with my script. I'm trying to loop over a bunch of CSV files, cut out the 3rd column, and append that to an output file as a new column. Here's what I have so far:</p>
  <pre><code>#!/bin/bash
  
  for n in ~/sampledir/*
  do
      awk -F &quot;,&quot; '{print $3&quot;,&quot;}' $n &gt;&gt; output.csv
  done
  </code></pre>
  <p>The output looks like this:</p>
  <pre><code>Column3,
  3,
  33,
  333,
  3333,
  33333,
  Column3,
  3,
  33,
  333,
  3333,
  33333,
  Column3,
  3,
  33,
  333,
  3333,
  33333,
  Column3,
  3,
  33,
  333,
  3333,
  33333,
  Column3,
  3,
  33,
  333,
  3333,
  33333,
  </code></pre>
  <p>What I want is for the new information to be appended to the CSV in columns, so rather than the output above, I want this:</p>
  <pre><code>Column3,Column3,Column3,Column3,Column3,Column3,
  3,3,3,3,3,3,
  33,33,33,33,33,33,
  333,333,333,333,333,333,
  3333,3333,3333,3333,3333,3333,
  33333,33333,33333,33333,33333,33333,
  </code></pre>
  <p>Any guidance would be helpful. Thanks y'all.</p>