Artificial intelligent assistant

Filtering the line with the largest value for a given ID I have a tabular file in which the first column has IDs and the second one has numeric values. I need to generate a file that contains only the line with the largest score for each ID. So, I want to take this: ES.001 2.33 ES.001 1.39 ES.001 119.55 ES.001 14.55 ES.073 0.35 ES.073 17.95 ES.140 1.14 ES.140 53.88 ES.140 18.28 ES.178 150.27 And generate this: ES.001 119.55 ES.073 17.95 ES.140 53.88 ES.178 150.27 Is there a way of doing this from a bash command-line?

Depending on the type of data, sorting may take a long time. We can get the result without sorting (but using more memory) like this:


awk 'a[$1]<$2{a[$1]=$2}END{for(i in a){print(i,a[i])}}' infile

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 9831dc7b472240a3cb0975981869c302