Skip to content

Instantly share code, notes, and snippets.

@rkennesson
Last active July 12, 2019 21:34
Show Gist options
  • Save rkennesson/a449471c9d1322809279e5143b710e2d to your computer and use it in GitHub Desktop.
Save rkennesson/a449471c9d1322809279e5143b710e2d to your computer and use it in GitHub Desktop.
function topcommands () {
#usage: topcommands [n]
# default is top 10 commands
if [ "$1" == "" ]; then
history | awk '{c[$2]++}END{for(i in c){print c[i] " " i}}' | sort -rn | head
else
history | awk '{c[$2]++}END{for(i in c){print c[i] " " i}}' | sort -rn | head -n "$1"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment