十四、檢視日志
1.0 cat -n xxx.log 檢視檔案并顯示行号
2.0 head -n 10 xxx.log 檢視檔案前10行
3.0 head -n -10 xxx.log 檢視檔案至倒數第十行(最後10不顯示)
4.0 tail -n 10 xxx.log 檢視檔案最後10行
5.0 tail -n +10 xxx.log 檢視檔案前10行
i) 根據關鍵詞過濾
cat -n test.log |grep “關鍵詞” ,擷取到關鍵詞所在行行資訊及行号,假設行号為100
cat -n test.log |tail -n +90|head -n 20 ,擷取[90, 110]行資訊,即關鍵詞前十行,後十行
ii) 根據日期 過濾