History





ヒストリー


DESC 過去に入力したコマンドを実行する 繰り返すときに便利
# ひとつ前を実行 ( 繰り返すときに便利 ) !! # 過去の履歴を Reverse Incremental Search c-r f と入力すると "f" に マッチするコマンドが表示される
直近のコマンドを実行する。
# 何かのコマンドを実行 grep "todo" `find -iname "*.h"` # ! の後の任意の文字でマッチする直近のコマンドを実行する。 !gr
履歴を移動する
# Previous c-p [↑] # Next c-n [↓]
ヒストリを削除する。
history -c
# 履歴の最大サイズを調べる。 echo $HISTSIZE # history で過去の履歴を表示 history 1 echo foo 2 echo bar 3 find . -name "*.txt" # 履歴 3 番目を実行 !3 find . -name "*.txt"
-> !id:pos:act // id 番目の CmdLine を pos 番目の token を act する !510:0 // 0 番目( cmd )の部分へ置換 // 直前の cmd を置換. 名前を探す際に便利 find -iname ".txt" ^txt^cpp


history


SYNTAX history [OP] [n] DESC Command 履歴出力 OP n : 出力する行数 POINT !! : 直前 !n : n 番目 !-n : n 番目前 !str: str で始まる最新 !?str?: str を含む cmdline # 過去 6 番目まで history 6 # "file" を history file として扱う # Default は $HISTFILE が使用される history file # /home/usr/.bash_history echo $HISTFILE # history の entry に追加( Store ) history -s "echo foo" history 2 echo foo history
$HISTFILE( ~/.bash_history ) に記録されている