2015 shaares
45 private links
45 private links
So good !
To prevent a command from being added to the history in the first place, make sure that the environment variable HISTCONTROL contains among its colon-separated values the value ignorespace, for example (add e.g. to .bashrc):
$ export HISTCONTROL=ignorespace
This will prevent any command with a leading space from being added to the history. You can then clear the history completely by running
$ history -c -w
^-- additional space character