Подход awk,
awk '
$1!="exon" { # If the first died is unequal to "exon"
if(previous)print previous # If there is a previous line then print it
print # Print the current line
previous=start=end=exon_seq="" # Set all variable to an empty string
next # Move on to the next line in the input file
}
{
if(exon_seq) { # if there is a sequence of lines with "exon in field 1
if(start<=$2 && end>=$3) # if the start value (field 2) of the previous line
# is less or equal to the current line and the end
# value of the previous line is greater than or
# equal to field 3 of the current line
next # then do nothing and read the next line
else # if there is no overlap,
print previous # then print the previous line
}
else { # if we are not already in the a sequence of
# "exon" lines, then this is the first one
exon_seq=1 # so exon_seq should become 1
}
previous=$0; start=$2; end=$3 # `start` become field2, `end` becomes field 3 and
# `previous` becomes the current record (line)
}
END{ # After all lines are processed
if(previous) print previous # If there still is a previous line, then print it
}
' file