clear history from shell

Ralf Mardorf silver.bullet at zoho.com
Thu May 19 06:20:54 UTC 2016


On Thu, 19 May 2016 06:51:51 +0100, Grizzly wrote:
>Wednesday, May 18, 2016  at 14:53, MR ZenWiz wrote:
>Re: clear history from shell (at least in part)
>
>>On Mon, May 16, 2016 at 9:08 AM, Grizzly
>><Real_Grizz_Adams at yahoo.co.uk> wrote:  
>
>>> It would be nice if there were a "Unique" switch for history so if
>>> a command has been used before (or maybe was executed from history
>>> itself) its not added to list again, just a thought  
>>
>>That's what the HISTCONTROL=erasedups is supposed to do.
>>
>>In my experience, this doesn't always (or often) work - I get scads of
>>duplicate entries within in terminal window, but I have mine set to
>>HISTCONTROL=ignoreboth:erasedups.  I'm not sure that works too well
>>either.  
>
>From what I have read (but not tested), it only works with consecutive
>commands i.e.
>
>Apt-get update
>Apt-get update
>
>would storee one Apt-get update
>
>but
>
>Apt-get update 
>Apt-get dist-upgrade
>Apt-get update
>Apt-get dist-upgrade
>
>would store them all?

What was your source of reading?

In my reply,
https://lists.ubuntu.com/archives/ubuntu-users/2016-May/285343.html , I
pointed something out, but beyond that I mentioned "erasedups" and
"ignoredups".

I didn't test it either, because I prefer to use a default history for
the very good reasons I already pointed out, but assumed I would like
to have another history, I would test it. Anyway, you are confusing
"erasedups" and "ignoredups".

$ man bash | grep erasedups -B5 -A5
HISTCONTROL
A colon-separated list of values controlling how commands are saved on
the history list.  If the list  of  values includes ignorespace, lines
which begin with a space character are not saved in the history list.
A value of ignoredups causes lines matching the previous history entry
to not be  saved.   A  value  of  ignoreboth is  shorthand for
ignorespace and ignoredups.  A value of erasedups causes all previous
lines matching the current line to be  removed from  the  history list
before that line is saved.  Any value not in the above list is
ignored.  If HISTCONTROL is unset, or does not include a valid value,
all lines read by the shell parser are  saved on  the history  list,
subject to the value of HISTIGNORE.  The second and subsequent lines of
a multi- line compound command are not tested, and are added to the
history regardless of  the  value  of HISTCONTROL.





More information about the ubuntu-users mailing list