I am using the Terminal app on OS X to try and clear my command history. The entries within my $HOME/.bash_history
file do not match what is returned by the history
command. The echo $0
command tells me that my Terminal session is using the bash shell (-bash
) so I would expect these to be the same.
Also, the history -c
command only clears the history that I see in the Terminal app with the history
command, it doesn't affect the contents of the $HOME/.bash_history
file. Please could someone help to explain my misunderstanding?
Best Answer
Ok, apologies, I just realised that the command history is cached in memory until the terminal session is exited cleanly. The
$HOME/.bash_history
file andhistory
command now match as expected.