title: awk - count number of occurences for a field in a line containing another specific field
body: <p>I have the following data structure:</p>
  
  <pre><code>apples    yellow
  apples    yellow
  apples    green
  apples    green
  apples    green
  
  grapes    yellow
  grapes    yellow
  grapes    yellow
  grapes    green
  
  lemons    yellow
  lemons    green
  lemons    green
  </code></pre>
  
  <p>Important: I don't know my list contains apples, grapes and lemons beforehand. If I need to count the number of times <code>$1</code> is <code>yellow</code> and then display <code>$1</code> with the number of <code>yellow</code> counts next to it, I can do this with GNU AWK:</p>
  
  <pre><code>awk '$2=="yellow" {yellowfruit[$1]++} END {for (fruit in yellowfruit) print fruit,yellowfruit[fruit]}'
  </code></pre>
  
  <p>...and get the expected result:</p>
  
  <pre><code>grapes 3
  lemons 1
  apples 2
  </code></pre>
  
  <p>How can I add another column which counts green occurences for each fruit type? I can't do <code>for (fruit in yellowfruit,greenfruit)</code> or like bash: <code>for (fruit in yellowfruit greenfruit)</code></p>