Hack 57. Eliminate the continuous repeated entry from history using HISTCONTROL

In the following example pwd was typed three times, when you do history, you can see all the 3 continuous occurrences of it. To eliminate duplicates, set HISTCONTROL to ignoredups as shown below.

# pwd

# pwd

# pwd

# history | tail -4
       44  pwd
       45  pwd
       46  pwd 
       47  history | tail -4

Note: There are three pwd commands in history, after executing pwd 3 times as shown above

# export HISTCONTROL=ignoredups

# pwd

# pwd

# pwd

# history | tail -3
       56  export HISTCONTROL=ignoredups
       57  pwd 
       58  history | tail -4

Note: There is only one pwd command in the history, even after executing pwd 3 times as shown above

Comments on this entry are closed.