新聞中心
history命令查看歷史記錄,找到要?jiǎng)h除的命令的編號(hào),然后使用history -d 編號(hào)命令刪除該條記錄。在Linux/Unix Bash shell中,我們可以通過(guò)以下步驟刪除歷史記錄中的一條命令:

1. 查看歷史記錄
我們需要查看當(dāng)前的歷史記錄,在Bash shell中,可以使用history命令來(lái)查看歷史記錄,這將顯示一個(gè)帶有歷史記錄編號(hào)的列表。
$ history
2. 找到要?jiǎng)h除的命令
在歷史記錄列表中找到要?jiǎng)h除的命令,每條命令都有一個(gè)唯一的編號(hào),
1 ls 2 cd .. 3 mkdir test 4 touch test.txt
在這個(gè)例子中,我們要?jiǎng)h除編號(hào)為3的命令(mkdir test)。
3. 刪除指定編號(hào)的命令
使用history d命令 followed by the command number you want to delete. In this case, we will use history d 3 to delete the command with the number 3.
$ history d 3
4. 確認(rèn)命令已刪除
再次運(yùn)行history命令以確保要?jiǎng)h除的命令已從歷史記錄中刪除。
$ history
現(xiàn)在,你應(yīng)該看到編號(hào)為3的命令(mkdir test)已從歷史記錄列表中刪除。
歸納一下,要從Linux/Unix Bash shell中刪除歷史記錄中的一條命令,你需要執(zhí)行以下操作:
1、使用history命令查看歷史記錄。
2、找到要?jiǎng)h除的命令及其編號(hào)。
3、使用history d命令 followed by the command number you want to delete.
4、再次運(yùn)行history命令以確保命令已刪除。
本文名稱:如何從Linux/UnixBashshell上刪除歷史記錄中的一條命令?
本文鏈接:http://m.5511xx.com/article/dpedpgc.html


咨詢
建站咨詢
