title: Merge all lines that are identical aside from a key field and make key field a range
body: <p>I've been looking at a lot of posts and haven't quite found what I'm looking for. I'm not sure how to go about taking the following sample data:</p>
  
  <pre><code>host1   input   nic1    ip1 ip2 PROT    30000   10
  host1   input   nic1    ip1 ip2 PROT    40000   10
  host1   input   nic1    ip1 ip2 PROT    50000   10
  host1   input   nic1    ip1 ip2 PROT    60000   10
  host1   input   nic1    ip3 ip2 PROT    10      30000
  host1   input   nic1    ip3 ip2 PROT    10      40000
  host1   input   nic1    ip3 ip2 PROT    10      50000
  host1   input   nic1    ip3 ip2 PROT    10      60000
  host1   output  nic1    ip2 ip1 PROT    10      30000
  host1   output  nic1    ip2 ip1 PROT    10      40000
  host1   output  nic1    ip2 ip1 PROT    10      50000
  host1   output  nic1    ip2 ip1 PROT    10      60000
  host1   output  nic1    ip2 ip3 PROT    30000   10
  host1   output  nic1    ip2 ip3 PROT    40000   10
  host1   output  nic1    ip2 ip3 PROT    50000   10
  host1   output  nic1    ip2 ip3 PROT    60000   10
  host1   output  loc     ip2 ip2 PROT    10      30000
  host1   output  loc     ip2 ip2 PROT    10      50000
  </code></pre>
  
  <p>And merge it into:</p>
  
  <pre><code>host1   input   nic1    ip1 ip2 PROT    30000:60000 10
  host1   input   nic1    ip3 ip2 PROT    10          30000:60000
  host1   output  nic1    ip2 ip1 PROT    10          30000:60000
  host1   output  nic1    ip2 ip3 PROT    30000:60000 10
  host1   output  loc     ip2 ip2 PROT    10          30000:50000
  </code></pre>
  
  <p>I have a large amount of data like this with the need to make ranges for multiple fields of a given line but I think if somebody can show me how to do it for one field as I have above, I should be able to figure the rest out. And if not I'll follow up :). Thanks in advance for any help.</p>