When I use Bash, how can I prevent a command from saving it in bash history? Well, per my tests, there are at least two ways.
1, Prepending one or more spaces to your command
With one or more spaces prepending in the command, it won’t saved in bash history file. Your command can run like this,
2, Unset the variable $HISTFILE before exiting your shell
$ unset HISTFILE
This does the trick, and you can test some similar vairables like HISTSIZE or HISTFILESIZE.