Given the following three column tab delimited list file, where value 1 and value 2 in each row represents a range in a given match, what is the simplest shell script/command that will identify all overlapping ranges for each match and determine the min and max value for the entire overlap? For a given match, the smallest value is always in the first column of the range. However, within a match the values in the columns are not necessarily sorted.
infile.txt:
match1 857 1107
match1 879 1128
match1 969 1126
match1 865 1115
match1 1296 1546
match1 1304 1554
match1 1318 1600
match1 1408 1562
match2 300 1100
match2 639 1225
match2 4299 6546
match2 5304 7754
outfile.txt:
match1 857 1128
match1 1296 1600
match2 300 1225
match2 4299 7754