如何使用#history -c 在终端中恢复我删除的历史记录

sat*_*ish 10 bash redhat-enterprise-linux

我已经使用#history -c 清除了终端中的所有历史记录。现在我想恢复我所有被清除的命令。请给我一个答复

Dav*_*ill 11

我想恢复我所有被清除的命令

  • history -c~/.bash_history外壳中清除。

  • bash不会立即将历史记录刷新到~/.bash_history.

  • ~/.bash_history直到您使用history -w.

  • 如果你真的想清除你需要history -cw在所有打开的 shell 中使用的历史记录。


如果你还没有使用history -w

  • 您可以使用 重新加载历史记录history -r

  • 如果您注销并再次登录,您的历史记录也将被恢复。


如果您history -w在一个 shell 中使用并且您打开了其他 shell

  • 您可以使用该 shell 保存您的历史记录history -w(尽管它与另一个 shell 的历史记录不同)

如果您在每个打开的 shell 中使用history -candhistory -w

  • 你的历史丢失了