tail
tail命令常使用選項-f
-f, --follow[={name|descriptor}]
output appended data as the file grows;
an absent option argument means 'descriptor'
例如:
tail -1000f sys.log
按回車鍵增加空白行,按Ctrl + C 結(jié)束
vi / vim
vi 文件名
如:vi sys.log
進(jìn)入文件后使用/字符(從光標(biāo)出向尾)或?字符(從光標(biāo)出向頭)搜索 + 回車鍵
找到內(nèi)容后按n跳到下一個,按h、j、k、l可以移動光標(biāo)
grep
grep用法可以很多種,列舉常用的。
用法:grep -C 20 “搜索字符” 文件名
-C:表示找到目標(biāo)時,同時顯示目標(biāo)上下20行內(nèi)容。文章來源:http://www.zghlxwxcb.cn/news/detail-817570.html
[shy@localhost ~]$ grep -C 2 123 01.log
123
456
789
123
iii
uuu
[shy@localhost ~]$ grep -C 1 123 01.log
123
456
789
123
iii
[shy@localhost ~]$ grep -C 1 '123' 01.log
123
456
789
123
iii
[shy@localhost ~]$ grep -C 1 "123" 01.log
123
456
789
123
iii
[shy@localhost ~]$
可以加 -n輸出行號:文章來源地址http://www.zghlxwxcb.cn/news/detail-817570.html
grep -C 1 -n "123" 01.log
到了這里,關(guān)于Linux查找日志常用命令的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!