Other ways to do this here as well:
Excellent answer. If you would rather preserve the chronological order (instead of the input order) for your commands, modify
dedup()by replacingawk '! x[$0]++' $@withtac $@ | awk '! x[$0]++' | tac– trusktr
https://superuser.com/questions/722461/how-can-you-remove-duplicates-from-bash-history
Also in vim text editor :sort u
If some of the suggestions including the ones above don't work immediately. After running the code I do:
history -c to clear the history first then restore the no duplications version over it:
cp temp.txt ~/.bash_history