I have an awk script to find the maximum value of the 2nd column of a 2 column datafile, but I need to find the top 5 maximum values of the 2nd column.
Here is the script that works for the maximum value.
awk 'BEGIN { subjectmax=$1 ; max=0} $2 >= max {subjectmax=$1 ; max=$2} END {print ""subjectmax" "max""}' filename
The data file contains the format of -
0001 1
0002 2
0003 3
0004 4
0005 5
0006 6
So the output would be
0006 6
I am looking for an output of
0006 6
0005 5
0004 4
0003 3
0002 2
Thanks