How to Clear Command Line History

If you’re a frequent command line user, you’re likely to have found the history command to be quite useful before, whether it’s for discovering your most frequently used commands, dumping history and searching it to find specific past commands, listing all defaults commands used, or whatever else. That said, there are some obvious situations where you may want to remove that history list entirely, be it for privacy or security purposes.
To clear out history, you just need to attach a -c flag to that same history command:
history -c
That will manually wipe the .bash_history file. Obviously that file could be targeted directly with rm as well, but it’s best to stick with the history command for a variety of reasons.
If you wish to verify the command worked, type ‘history’ again as usual, and you’ll discover the only command listed is “history -c”. The brief video below demonstrates this entire process.
This should work the same at any bash shell, regardless of it being in Mac OS X or linux.
Thanks to Ado for the tip idea

Should work with other shells as well, but .sh_history, .tsch_history etc are easy to remove anyway.
Thanks I didn’t know this command It’s good
Keeping the history file can be useful:
Bash has an instant reverse search function. To search through old commands, press cmd-R and then start typing any part of a command previously used. Quite handy…
I think you mean ctrl-R.
if you want exit without saving the history session:
$ kill -9 $$
how about if you dont want history saved at all and tired of typing history -c. HISTSIZE=0 will not save anything to history.
bash clean history
alias cleanH=’history -c;echo “”> ~/.bash_history’
add alias in ~/.bashrc
cya