Created
March 10, 2021 17:54
-
-
Save alejo4373/51577d53c91a4921841276beec979769 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 ~/.zsh_history | # Read file | |
awk 'BEGIN { FS="[; ]" } { print $3}' | # Split file in fiels separated by a ; or a space and print the 3rd 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