history|awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head #### history | perl -le 'while($l = <>) {$n=${[split(/\s+/,$l)]}[2];$h{$n}++;} $i=0;foreach $k (reverse sort {$h{$a}<=>$h{$b}} keys %h) {last if $i > 9; print "$h{$k} $k"; $i++;}' #### history | perl -le 'while($l = <>) {$n=${[split(/\s+/,$l)]}[2];$h{$n}++;} $i=0;@a=reverse sort {$h{$a}<=>$h{$b}} keys %h; print "$h{$a[$_]} $a[$_]" for (0..9)'