Or to phrase it differently, why would you want to prevent commands from being written to the bash history?
(Inspired by a related question.)
Or to phrase it differently, why would you want to prevent commands from being written to the bash history?
(Inspired by a related question.)
The one thing I use that the initial space for is if I want to be able to restart an older commandline that starts with the same command (!ls
e.g.) and I need to be able to re-execute the older one, but not the newer.
The other time I use it is in the (seldom) cases I give a password on the commandline, I rather not have those stored in the .bash_history
file once I exit bash
.
I'd rather not know how many times I've played crawl!
Occasionally I like to do a history | awk '{print $2}' | sort -n | uniq -c | sort -n | tail
to see my most-issued commands. I want to see a ranking in there of commands I find interesting (things like ls
, svn
, p4
, for
, and cd
) and I feel better when I don't see games in that list. So when I run something that I don't want to see in that list, I prefix it with a space.
In addition to Anthon: It is not just possible to avoid similar command lines in history but from time to time there is a need to do that: I often analyze OpenPGP certificates in the shell. That means that 15 lines (sometimes more) are thrown in the console. You do that a few times and your history is full. Even worse: History does not work well if the command covers the whole screen (bash). The start of the command is not shown correctly and thus can hardly be edited.
Thus I keep a rather short one of these command lines in the history and block the other ones.
export HISTFILESIZE=-1
– Jorge V.
Mar 10 '16 at 00:12