首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在bash历史中隐藏“历史-d”

在bash历史中隐藏“历史-d”
EN

Ask Ubuntu用户
提问于 2017-12-07 14:51:23
回答 1查看 3.5K关注 0票数 14

如果我在bash中不小心输入我的密码或其他敏感的内容,我可以很容易地用history -d ROW#删除这一行,但是历史上总是会留下history -d ROW#命令,向每个人显示有人纠正了错误。

我可以在命令中附加一些东西以防止它出现在bash历史中吗?

EN

回答 1

Ask Ubuntu用户

发布于 2017-12-07 15:08:00

一种方法是设置HISTIGNORE环境变量。来自man bash

代码语言:javascript
复制
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-空间内的解决方案。。

所以,例如

代码语言:javascript
复制
HISTIGNORE='history -d*'

如果您希望它是持久的,从您的~/.bashrc导出它

代码语言:javascript
复制
export HISTIGNORE='history -d*'
票数 12
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/984117

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档