kon*_*qui 2 command-line bash command-history
使用以下内容搜索传递的日志文件:
cat /path/to/logfile | grep -iEw 'some-ip-address-here|correspondig-mac-adress-here'
这给了我到目前为止所有通过的日志行,所以我可以看到已经发生了什么。现在,我也想看看发生了什么事情,所以我需要换cat
用tail -f
给我这个:
tail -f /path/to/logfile | grep -iEw 'some-ip-address-here|correspondig-mac-adress-here'
您可以使用!!:*
来引用除最后一个命令行的第零个以外的所有单词。
!!
指的是前一个命令,:
将事件规范与单词指示符分开,*
指除第零个以外的所有词。
这是来自HISTORY EXPANSION
bash(1)的部分。
wieland@host in ~» cat foo | grep bar
bar
wieland@host in ~» tail -f !!:*
tail -f foo | grep bar
bar
Run Code Online (Sandbox Code Playgroud)
您还可以在^string1^string2^
重复最后一个命令的地方使用快速替换,替换string1
为string2
:
wieland@host in ~» cat foo | grep bar
bar
wieland@host in ~» ^cat^tail -f
tail -f foo | grep bar
bar
Run Code Online (Sandbox Code Playgroud)