How do I get the total number of distinct values in a column in a CSV?
<p>I have a CSV file named <code>test.csv</code>. It looks like this:</p>

<pre><code>1,Color
1,Width
2,Color
2,Height
</code></pre>

<p>I want to find out how many distinct values are in the first column. The shell script should return <code>2</code> in this case.</p>

<p>I tried running <code>sort -u -t, -k2,2 test.csv</code>, which I saw on another question, but it printed out far more info than I need.</p>

<p>How do I write a shell script that prints the number of distinct values in the first column of <code>test.csv</code>?</p>