I am trying to sort out the minimum value out of a text file, which contains repeated names, but different values.
Peter 0.19827
Wilson 0.99234
Peter 0.08234
May -0.45623
Joe 0.88765
Wilson -0.88341
Joe 0.99943
I,ve tried this, but its not working: (I prefer awk one-liner)
cat aaa.txt | sort -k2nr | awk '{if ($2<min[$1]) {min[$1]=$2}}END{for (i in min) {print i,min[i]}}' | less
The expected output:
Peter 0.08234
Wilson -0.88341
May -0.45623
Joe 0.88765