title: How do I print out the count of unique matches with grep?
body: <p>Lets say I have millions of packets to look through and I want to see how many times a packet was sent to a certain port number.</p>
  
  <p>Here are some of the packets:</p>
  
  <pre><code>10:27:46.227407 IP 85.130.236.26.54156 &gt; 139.91.133.120.60679: tcp 0
  10:27:46.337038 IP 211.142.173.14.80 &gt; 139.91.138.125.56163: tcp 0
  10:27:46.511241 IP 211.49.224.217.3389 &gt; 139.91.131.47.6973: tcp 0
  </code></pre>
  
  <p>I want to look through the 2nd port number here so:</p>
  
  <p>60679, 53163, 6973, etc</p>
  
  <p>So I can use:</p>
  
  <pre><code>grep -c '\.80:' output.txt
  </code></pre>
  
  <p>To count all the times port 80 was used. But is there a way for it to display all the ports that were used and how many times it was found in this file. Something like this and preferable sorted too so I can see which ports were used most often:</p>
  
  <pre><code>.80: - 54513
  .110: - 12334
  .445: - 412
  </code></pre>