title: Cut partial element from specific column in print output
body: <p>For a while now I've been using a simple command to extract data from netstat to show how many connections to a server are coming from a specific IP.</p>
  
  <p>I'm now trying to migrate that command, while adding a bit more detail, using ss but I'm getting a bit stuck on how to remove a certain element from a specific column.</p>
  
  <p>What I have so far is the following:</p>
  
  <pre><code>ss -t 2&gt;/dev/null | awk -v OFS='\t\t' '{print $4, $5}' | sort | uniq -c | sort -nr
  </code></pre>
  
  <p>and that will output something similar to:</p>
  
  <pre><code>  1 Local                           Address:Port
    1 172.31.6.21:imaps               124.170.xxx.xxx:47498
    1 172.31.6.21:imaps               124.170.xxx.xxx:47122
  </code></pre>
  
  <p>The problem I have here is that I cannot work out how to get consolidated values for each source IP that ignores the ":Port" factor. I've tried a few things using the cut command, but that also affects the first column, so the output is not as precise as desired.</p>
  
  <p>The type of output I want to be able to see would be:</p>
  
  <pre><code>  1  Local                           Address:Port
    22 172.31.6.21:imaps               124.170.xxx.xxx
    31 172.31.6.17:http                134.162.xxx.xxx
  </code></pre>
  
  <p>The local IP, protocol type, and source IP are what is important from the results. I want to remove the port element, so that when I use the sort function, I can see the number of connections to a specific local IP for a specific protocol from a specific source IP.</p>