linux - 在 Centos 6.2 中删除 bash 历史记录

标签 linux bash shell

我不小心将一大块文本复制到我的 Centos6.2 shell 中,它在我的 bash 历史记录中让我很烦恼,我该如何删除它?

我尝试运行 history -d {{ number }} 但下次打开 shell 时它会返回:(

此外,当我尝试在 for i in list 循环中使用 history -d $i 时 ,我不认为它删除了任何东西,因为它们在子 shell 中运行。

最佳答案

您可以使用以下命令来清理.bash_history文件:

history -w 
history -c

要删除特定行,请使用以下命令:

history -d <line_number> // deletes the line from history in memory

history -w 会将当前内存中的更改写入 .bash_history 文件。

关于linux - 在 Centos 6.2 中删除 bash 历史记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37653054/

相关文章:

Bash 根据匹配变量将文件复制到 sudirectories

python - 由 python subprocess.Popen(shell=True) 创建的进程的 pid 不是生成的 shell 的 pid

linux - 如何在 google colab 中启用拼写检查器(colab 在 linux 操作系统上运行)?

linux - 基于两个条件的嵌套查找

javascript - 与Node.js的长连接,如何减少内存使用,防止内存泄漏?还与 V8 和 webkit-devtools 相关

bash - 我如何grep反引号?

regex - 在 sed 和 awk 中使用正则表达式

linux - Bash 函数在后台自动运行命令并拒绝

php - 是否有类似 activerecord 的数据库模式迁移的独立替代方案?

regex - 在多个日志文件中查找模式?