Last active
March 2, 2022 00:42
-
-
Save bugre/c8050dc34810ea7b1d4dba92f40bb9e0 to your computer and use it in GitHub Desktop.
Bash history deduplicate / simplify / cleanup
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
## ATTENTION: Complete purges history.. make a backup if you want.. | |
# Clear bash history file and loaded history. | |
> ~/.bash_history && history -c | |
## deduplicate | |
## add to ~/.bashrc && ~/.bash_profile | |
HISTCONTROL=ignoreboth:erasedups | |
HISTCONTROL=ignoreboth:erasedups | |
HISTSIZE=50000 | |
HISTFILESIZE=100000 | |
HISTTIMEFORMAT="%F %T " | |
shopt -s histappend | |
## deduplicate a history file that was not previusly deduped. | |
## clean / dedub / reload / write | |
tac ~/.bash_history | awk '!x[$0]++' | tac >hist1 | |
> ~/.bash_history && history -c | |
history -r ./hist1 | |
history -w | |
## another option, | |
shopt -s histappend | |
export HISTCONTROL=ignoreboth:erasedups | |
export UPDATE_HIST="history -n; history -w; history -c; history -r" | |
tac ~/.bash_history | awk '!x[$0]++' | tac /tmp/tmphist; mv -v /tmp/tmphist ~/.bash_history | |
rm /tmp/tmpfile | |
## check this post: https://antofthy.gitlab.io/software/history_merge.bash.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment