Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

If I type the following:

history -c
history

I get 1110 history.

Why does clearing the command history not reset the counting to 1 and how can I reset the count?

Note: It is resetting the number, just not to 1. If I type 5 commands, the number changes to 1114 but history -c only resets it to 1110.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

From bash man page:

On startup, the history is initialized from the file named by the variable HISTFILE (default ~/.bash_history)...

When an interactive shell exits, the last $HISTSIZE lines are copied from the history list to $HISTFILE. If the histappend shell option is enabled (see the description of shopt under SHELL BUILTIN COMMANDS below), the lines are appended to the history file, otherwise the history file is overwritten...

So, only on exit the file ~/.bash_history is updated, and if histappend is set, the default, that file is not overwritten.

My suggestion, remove ~/.bash_history, then perform history -c.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.