Skip to content

Instantly share code, notes, and snippets.

@Adobe-Android
Last active April 23, 2021 19:44
Show Gist options
  • Save Adobe-Android/848dfec18152f4969b8d3a855e55b67b to your computer and use it in GitHub Desktop.
Save Adobe-Android/848dfec18152f4969b8d3a855e55b67b to your computer and use it in GitHub Desktop.
A simple way to check your most frequently used Linux commands
#!/bin/bash
# Reads from specified shell history file.
HISTFILE=~/.bash_history
# Enable history. Disabled by default in a non-interactive shell (e.g. scripts like this).
# Uses awk to get just the command name from shell history, sorts list by command name, filters out non-unique data, sorts by frequency, grabs top 5.
set -o history
history | awk '{print $2}' | sort | uniq -c | sort -nr | head -5
#!/bin/fish
# Uses awk to get just the command name from shell history, sorts list by command name, filters out non-unique data, sorts by frequency, grabs top 5.
history | awk '{print $1}' | sort | uniq -c | sort -nr | head -5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment