さまざまなbash履歴を見る

さまざまなbash履歴を見る

このhistoryコマンドは、現在のセッションのすべての履歴をリストします。良い:

1 ls 
2 cd /root
3 mkdir something
4 cd something
5 touch afile
6 ls
7 cd ..
8 rm something/afile
9 cd ..
10 ls
11 history

興味のあるアイテムを検索するには、次のパイプラインをhistory使用できます。grep

history | grep ls
1 ls
6 ls
10 ls

次の最後の3つのコマンドも表示できます。

history 3
11 history
12 history | grep ls
13 history 3

しかし、特定の範囲の記録をどのように取得できますか?たとえば、

history range 4 7
4 cd something
5 touch afile
6 ls
7 cd ..

ベストアンサー1

historyあなたはそれを使用することができますfc、範囲を選択できます。

fc -l 4 7

おすすめ記事