title: How to parse a CSV file in Bash?
body: <p>I'm working on a long Bash script.  I want to read cells from a CSV file into Bash variables.  I can parse lines and the first column, but not any other column.  Here's my code so far:</p>
  
  <pre><code>
    cat myfile.csv|while read line
    do
      read -d, col1 col2 &lt; &lt;(echo $line)
      echo "I got:$col1|$col2"
    done
  </code></pre>
  
  <p>It's only printing the first column.  As an additional test, I tried the following:</p>
  
  <p><code>read -d, x y &lt; &lt;(echo a,b,)</code></p>
  
  <p>And $y is empty.  So I tried:</p>
  
  <p><code>read x y &lt; &lt;(echo a b)</code></p>
  
  <p>And $y is <code>b</code>.  Why?</p>