Get highest range from the overlapping ranges : <p>I have a file with ranges. I want the highest ranges from the list and remove other small overlapping ranges:</p>

<pre><code>chr1A   77568   86766
chr1A   203138  204427
chr1A   204428  222994
chr1A   204428  206534
chr1A   206538  207965
chr1A   207967  213097
chr1A   213098  221111
chr1A   213098  213863
chr1A   213864  214195
chr1A   214196  221111
chr1A   221112  222994
chr1A   222995  223876
chr1A   223882  227109
chr1A   305432  314629
chr1A   323643  325976
chr1A   431741  451601
chr1A   431741  435137
chr1A   435141  436568
chr1A   436570  441700
chr1A   441701  449710
chr1A   441701  442466
chr1A   442467  442798
chr1A   442799  449710
chr1A   449711  451601
</code></pre>

<p>For example:</p>

<p>The first and second ranges are unique so these are kept.</p>

<p>Third to 11th ranges have overlapping, only highest one <code>chr1A   204428  222994</code> is kept and so on.</p>

<p>I want the output like this:</p>

<pre><code>chr1A   77568   86766
chr1A   203138  204427
chr1A   204428  222994
chr1A   222995  223876
chr1A   223882  227109
chr1A   305432  314629
chr1A   323643  325976
chr1A   431741  451601
</code></pre>

<p>I hope to get the solution in perl, bash or any other unix tool. Thanks</p>
