How to get a list of most used terminal commands
There are a bunch of terminal commands to be used everyday. But I just want to have a rough impression which are most used?
How to get the list of the commands?
My solution is as below:
history | awk '{$1="";print}' - | sort | uniq -c | sort -r > all_terminal_commands_history.txt
This roughly means that get the commands history, print all columns except first one, sort, count, descendent sort and send the result into a file.
The result of the file likes below:
1124 git status
400 ll
367 git log --oneline
204 task
154 git log
141 pwd
137 git branch
126 ..
116 git push
102 git remote -v
81 git add .
61 git branch -r
57 j terminal
55 git checkout master
54 git checkout main
References
Sort and count number of occurrence of lines - Unix & Linux Stack Exchange
How to print all columns except first column in Linux bash shell ? | New Generation Enterprise Linux
本作品采用《CC 协议》,转载必须注明作者和本文链接