Analyze history for most used commands

With history and a little bit of awk we make the magic. List commands in history by usage. Two examples above, the simple one and the advanced where the arguments to the commands are shown.


 

history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head

#Advanced version
history | awk '{a[$2 " " $3 " " $4 " " $5]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head -n+25


Posted

in

by