Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can anybody confirm if by setting the the following env variables under debian lenny will make previous history entries not to be saved. GNU bash, version 3.2.39(1)-release

export HISTCONTROL=ignoreboth
export HISTSIZE=500

I have added them to my /etc/bash.bashrc but I keep getting repeated commands.

share|improve this question

The options "ignoreboth" and "ignoredups" only prevent duplicates of the immediately preceding command from being added to the history. Earlier duplicates have no effect.

$ echo $HISTCONTROL
ignoreboth
$ echo a
a
$ echo b
b
$ echo b
b
$ echo a
a
$ history 4
1047  echo a
1048  echo b
1049  echo a
1050  history 4

As you can see echo a appears twice and echo b appears once.

You may be looking for the "erasedups" option.

$ echo $HISTCONTROL
ignoreboth:erasedups
$ echo c
c
$ echo d
d
$ echo d
d
$ echo c
c
$ history 4
1076  echo $HISTCONTROL
1077  echo c
1078  echo d
1079  history 4

Here both echo c and echo d appear only once.

share|improve this answer
    
erasedups is very usefull - thanks for pointing out! – ThorstenS Mar 15 '10 at 6:51
    
that's just wonderfull...thx... – j-p Mar 26 '14 at 10:32

Try using ignoredups intead of ignoreboth, add it to the /etc/profile file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.