I have a 3 column file and I want to find the maximum value of the third column with rows with same first column and have also the second column in output.
Input:
1 234 0.005
1 235 0.060
1 236 0.001
2 234 0.010
2 235 0.003
2 236 0.003
3 234 0.004
3 235 0.100
3 236 0.004
Desired output:
1 235 0.060
2 234 0.010
3 235 0.100
I found this hint from previous questions but I do not know how to have also the second column:
!($1 in max) || $3>max[$1] { max[$1] = $3 }
END {
PROCINFO["sorted_in"] = "@ind_num_asc"
for (key in max) {
print key, max[key]
}
}