歴史 コマンド 以前に実行されたコマンドを表示するために使用され、リストすることもできます。
この機能はBourneシェルでは使用できませんでした。
BashとKornは、実行されたすべてのコマンドがイベントとして扱われ、必要に応じて呼び出したり変更したりできるイベント番号に関連付けられるこの機能をサポートしています。これらのコマンドは履歴ファイルに保存されます。 Bashシェルの履歴 コマンドは、コマンドの全リストを表示します。
構文:
history

重要なポイント
- 次のように実行された限られた数のコマンドを表示します:
history 5

注:
コマンドは、イベント番号を使用して実行することもできます。
例:
!231

2. :p を使用して、コマンドを実行する前に印刷することもできます。 コマンドのイベント番号の後。
例:
!231:p

3.履歴リストから6番目のコマンドを実行するには下 :
!-6

4.このコマンドはgrepと一緒に使用することもできます:
例:
history | grep yum

5.最新のコマンドは!!を使用して表示できます
例:
!!

6.したがって、変数 HISTFILEを保存せずにコマンドを実行する必要がある場合を想定します。 設定を解除する必要があります。
したがって、コマンドは次のようになります。
例:

7.コマンドは、コマンドの一部を使用して実行することもできます。
例:
!command_starting_string

8.履歴はhistory-d event_numberを使用して削除することもできます 。
例:
history -d 566

注:
「.bash_history 」隠しファイルには、ユーザーが作成したすべてのコマンドが保存されます。すべてのユーザーには、スーパーユーザーの「root」でさえもbashの履歴があります。
9. history -cを使用して履歴全体を削除できます オプションですが、「 .bash_history」から削除することはできません 「。
例:
history -c

10.したがって、「。bash_history」ファイルから履歴全体を削除するには、次のコマンドを使用できます:
echo " " > .bash_history
11.履歴リストのサイズも知ることができます:
echo $HISTSIZE
