如果我在bash中不小心输入我的密码或其他敏感的内容,我可以很容易地用history -d ROW#删除这一行,但是历史上总是会留下history -d ROW#命令,向每个人显示有人纠正了错误。
我可以在命令中附加一些东西以防止它出现在bash历史中吗?
发布于 2017-12-07 15:08:00
一种方法是设置HISTIGNORE环境变量。来自man bash
HISTIGNORE
A colon-separated list of patterns used to decide which command
lines should be saved on the history list. Each pattern is
anchored at the beginning of the line and must match the com‐
plete line (no implicit `*' is appended). Each pattern is
tested against the line after the checks specified by HISTCON‐
TROL are applied. FWIW,这是默认的HISTCONTROL,它提供了类型a-空间内的解决方案。。
所以,例如
HISTIGNORE='history -d*'如果您希望它是持久的,从您的~/.bashrc导出它
export HISTIGNORE='history -d*'https://askubuntu.com/questions/984117
复制相似问题