Created
March 10, 2021 18:03
-
-
Save alejo4373/af3d02995674dce79635bd9dab30f241 to your computer and use it in GitHub Desktop.
Program to read your zsh history and output the 10 most common commands in it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat ~/.bash_history | # Read file | |
awk 'BEGIN { FS=" " } { print $1 }' | # Split file in fields separated by a space and print the 1st field | |
sort | # Sort each line lexicographically | |
uniq -c | # Count number of times a line occurs | |
sort -n -r | # Sort numerically and in reverse order | |
head # print the head of the output (first 10 lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment