title: Can sort | uniq or sort | awk count repeated values from one column?
body: <p>Using the following data:</p>
  
  <pre><code>$cat p1.csv
  R,3
  R,4
  S,1
  S,2
  S,3
  R,2
  T,4
  R,3
  ST,4
  RST,2
  RSTR,4
  </code></pre>
  
  <p>First sort based on column 2:</p>
  
  <pre><code>$cat p1.csv | sort -t "," -k2
  S,1
  R,2
  RST,2
  S,2
  R,3
  R,3
  S,3
  R,4
  RSTR,4
  ST,4
  T,4
  </code></pre>
  
  <p>I want to count the number of 1's, 2's, 3's, and 4's from column two. Something like $cat p1.csv | sort -t "," -k2 |  uniq -f2 -c .....Can uniq be applied to one column? The -f2 doesn't properly apply uniq to the correct field.  The output should take the first instance of a unique value in column two and count the number of them.  Hence, the data must first be sorted on column two.  A correct output would look like:</p>
  
  <pre><code>1 S,1
  3 R,2
  3 R,3
  4 R,4
  </code></pre>
  
  <p>Suggestions?</p>