Hello,
I want to get the maximum value of each record separated by empty line based on the 3rd column of each row within each record?
Input:
A1 chr5D 634 7 82 707
A2 chr5D 637 6 82 713
A3 chr5D 637 5 82 713
A4 chr5D 626 1 82 704
A5 chr5D 723 0 1 723
A6 chr5D 734 12 1 722
A7 chr5D 719 3 1 715
B5 chr6B 344 2 64 403
B6 chr6B 738 1 1 735
B7 chr6B 738 5 1 732
B8 chr6B 738 1 1 735
B9 chr6D 732 0 1 732
B10 chr6D 735 1 1 735
B11 chr6D 735 1 1 735
C1 chr6D 735 0 1 735
C2 chr6D 735 2 1 732
C3 chr6D 735 0 1 735
C4 chr7A 678 0 1 678
C5 chr7A 681 10 1 660
C6 chr7A 678 0 1 678
C7 chr7A 674 11 42 687
Output:
A6 chr5D 734 12 1 722
B8 chr6B 738 1 1 735
C3 chr6D 735 0 1 735
C5 chr7A 681 10 1 660
So far, I have tried:
awk 'BEGIN{FS="\n"; RS=""} $3 > max[NR] {maxline[NR]=$0} END{ for (i in maxline) {print maxline}}' input.tab
but it did not give what I expected.
There are several issues with my script.
1) $3 is for each line, but not correct within each record;
2) same issue with $0;
It seems to me the trick is the FS value and maxline[NR]=$0 in my case.
Thanks a lot!