title: How can I parse CSV files on the Linux command line?
body: <p>How can I parse CSV files on the Linux command line?</p>
  <p>To do things like:</p>
  <pre><code>csvparse -c 2,5,6 filename
  </code></pre>
  <p>to extract fields from columns 2, 5 and 6 from all rows.</p>
  <p>It should be able to handle the csv file format: <a href="https://www.rfc-editor.org/rfc/rfc4180" rel="nofollow noreferrer">https://www.rfc-editor.org/rfc/rfc4180</a> which means <strong>quoting fields and escaping inner quotes as appropriate</strong>, so for an example row with 3 fields:</p>
  <pre><code>field1,&quot;field, number &quot;&quot;2&quot;&quot;, has inner quotes and a comma&quot;,field3
  </code></pre>
  <p>so that if I request field 2 for the row above I get:</p>
  <pre><code>field, number &quot;2&quot;, has inner quotes and a comma
  </code></pre>
  <p>I appreciate that there are numerous solutions, Perl, Awk (etc.) to this problem but I would like a native bash command line tool that does not require me to invoke some other scripting environment or write any additional code(!).</p>