Skip to main content
4 of 5
Markup
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Check if the 2nd and the 3rd columns are repeating, print the first element in 5th and the last element in 6th column

The thing I wanna do is to check if the 2nd and the 3rd columns are repeating, print the first element in 5th and the last element in 6th column with their corresponding 4th column.

Example input looks like this:

Chr1    39584   39678   Chr1    39653   39654
Chr1    39584   39678   Chr1    39654   39655
Chr1    39584   39678   Chr1    39677   39678
Chr1    40023   40039   Chr1    40038   40039
Chr1    283979  283993  Chr1    283979  283980
Chr1    283979  283993  Chr1    283980  283981
Chr1    283979  283993  Chr1    283989  283990
Chr1    283979  283993  Chr1    283990  283991
Chr1    283979  283993  Chr1    283992  283993

Desired output looks like this:

Chr1    39653   39678
Chr1    40038   40039
Chr1    283979  283993

Thanks!