or easier and shorter:
printf PaSSw0rd | sha1sum printf PaSSw0rd | sha1sum > echo test
test
> history
...
6730 echo test
6731 history HISTCONTROL=ignorespace
Or even better, though unrelated to this topic... Also get it to ignore duplicates that come next to each other. HISTCONTROL=ignoredups:ignorespace python -c 'import hashlib; from getpass import getpass; s = hashlib.sha1(); s.update(getpass()); print s.hexdigest()' python -c 'import hashlib; print hashlib.sha1("reALpassWORD12%12").hexdigest()'
and then: history -d $((HISTCMD-2))
to delete the last entry in the bash history.