Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bash history HISTFILE deduplication while preserving order
# backup HISTFILE
cp ~/.bash_history{,.bak}
# deduplicate
nl ~/.bash_history.bak | sort -k2,2 -k1,1nr | uniq -f1 | sort -k1,1n | cut -f2 > ~/.bash_history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment