4 ms·
You can pre-sort as greyfade mentions, or do it within awk itself: awk '!/#/ {a[$2]++}END{for (i in a) print a[i],i | "sort -nk1"}' data.txt 1 0 1 202 1 2
by sikhnerd 13y ago
You can pre-sort as greyfade mentions, or do it within awk itself:
awk '!/#/ {a[$2]++}END{for (i in a) print a[i],i | "sort -nk1"}' data.txt
1 0
1 202
1 289
1 291
1 298
1 311
4 104