Skip to content

Instantly share code, notes, and snippets.

@JasonkayZK
Last active October 20, 2022 06:01
Show Gist options
  • Save JasonkayZK/f3589c2f0af0cd15ab81abf94529aa90 to your computer and use it in GitHub Desktop.
Save JasonkayZK/f3589c2f0af0cd15ab81abf94529aa90 to your computer and use it in GitHub Desktop.
Show frequently-used command
# CentOS
history | awk '{CMD[$4]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
# Ubuntu
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
# MacOS(zsh)
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment