history -cw does not overwrite ~/.bash_history file
4
votes
2
answers
258
views
I use Arch Linux and bash. I've identified the following and can't understand how it works.
The first issue is:
history -cw
doesn't clear ~/.bash_history
file but history -c ; history -w
does.
The second one is:
When I open the shell and execute something like these:
$ first
$ second
$ history -c
$ third
and close the shell, ~/.bash_history
is supplemented with a line third
. I expect ~/.bash_history
to contain the single line third
.
My shopt histappend
is off, doesn't this mean that the history file needs to be overwritten? It's not critical for me, but I want to understand how it works.
Asked by hlooo
(41 rep)
Jul 6, 2025, 02:42 PM
Last activity: Jul 7, 2025, 07:52 AM
Last activity: Jul 7, 2025, 07:52 AM