![历史命令中的“n”和“r”选项有什么区别?](https://linux22.com/image/180583/%E5%8E%86%E5%8F%B2%E5%91%BD%E4%BB%A4%E4%B8%AD%E7%9A%84%E2%80%9Cn%E2%80%9D%E5%92%8C%E2%80%9Cr%E2%80%9D%E9%80%89%E9%A1%B9%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%9F.png)
我已阅读history
命令帮助页面并尝试了这两个选项(n
& r
)。据我了解,这两个选项都确保历史文件在当前 shell 中被读取并且有效,因此它执行相同的操作。我想知道它有何不同?
-n Append the history lines not already read from the history file
to the current history list. These are lines appended to the
history file since the beginning of the current Bash session.
-r Read the current history file and append its contents to the history list.
答案1
附加-r
整个文件,-n
仅附加自会话开始以来添加到其中的行。