> http://mywiki.wooledge.org/BashFAQ/088
The advice here to use awk to "compress" log files seems a bit dated. Bash now allows you to set in .bashrc: export HISTCONTROL=erasedups I don't know that there's an "ultimate answer" to history management. Personally, for years I have had my prompt set to show the history number of the current command, so I can look up on the screen and just enter !505 to reuse a previous comment. I reality, I never use this, but a terminal wouldn't feel like a terminal, for me now, without having numbered prompts up the screen. More practically I tend to use tmux and open new panes for each task or task group, keeping task sets short and closing the pane when I've done that little job (or sub-job). This allows Bash itself to manage its history more efficiently. If I need to use a previous command and ctrl-R doesn't easily find it, I tend to just `history | grep hint` to find it. I also set HISTSIZE and HISTFILESIZE to 900, so to maximise the number of previous commands available to me by typing only a three digit !321. Stroller.