Hack 58. Erase duplicates across the whole history using HISTCONTROL

by Ramesh

The ignoredups shown above removes duplicates only if they are consecutive commands. To eliminate duplicates across the whole history, set the HISTCONTROL to erasedups as shown below.

# export HISTCONTROL=erasedups

# pwd

# service httpd stop

# history | tail -3
       38  pwd
       39  service httpd stop
       40  history | tail -3

# ls -ltr

# service httpd stop

# history | tail -6
       35  export HISTCONTROL=erasedups
       36  pwd
       37  history | tail -3
       38  ls –ltr
       39  service httpd stop
       40  history | tail -6

Note: The previous service httpd stop after pwd got erased

Comments on this entry are closed.

Previous post:

Next post: