Assume I got this logfile:
100.1 500
100.2 501
100.2 501
100.2 501
100.1 501
666.2 501
300.1 555
300.1 501
100.1 300
100.1 300
100.1 300
102.3 500
202.1 500
301.2 300
Any duplicate lines should be removed first. Then swap the columns. And then group lines based on first column value (501, 500, etc), sorting such groups based on the count of these values. Finally, sort the second column value of such groups in descending order.
This is how far I've gotten:
$ awk '{!seen[$2, $1]++}; END {for (i in seen) print i}' $filename |
sort -k2 -n -r
555?300.1
501?666.2
501?300.1
501?100.2
501?100.1
500?202.1
500?102.3
500?100.1
300?301.2
300?100.1
This is the expected output:
501 666.2
501 300.1
501 100.2
501 100.1
500 202.1
500 102.3
500 100.1
300 301.2
300 100.1
555 300.1