文章目錄
history 用法彙總
命令 | 用法 |
---|---|
history |
列出全部歷史命令 |
history 數字# |
列出最近的#條命令 |
history -c |
將目前shell中的所有history命令消除【就是按↑翻不到了】,對命令歷史文件沒有影響 |
history -w |
將本次登錄的命令寫入命令歷史文件中, 默認寫入~/.bash_history【其實是會自動保存的】 |
history -r |
將命令歷史文件中的內容讀入到目前shell的history記憶中【就是按↑能翻到】 |
注:~/.bash_history文件會自動保存當前用戶使用過的歷史命令
history——列出全部歷史命令
history 數字#——列出最近的#條命令
history -c——將目前shell中的所有history命令消除,對命令歷史文件沒有影響
history -w——將本次登錄的命令寫入命令歷史文件中, 默認寫入~/.bash_history
history -r——將命令歷史文件中的內容讀入到目前shell的history記憶中
先history -c
——將目前shell中的所有history命令消除,會發現按↑翻不到歷史命令
再history -r
——將命令歷史文件中的內容讀入到目前shell的history記憶中,會發現按↑可以翻到歷史命令