1、查看日志 前 n行:
cat 檔案名 | head -n 數量
demo:
cat test.log | head -n 200 # 查看test.log前200行
2、查看日志 尾 n行:
cat 檔案名 | tail -n 數量
demo:
cat test.log | tail -n 200 # 查看test.log倒數200行
3、根據 關鍵詞 查看日志 并回傳關鍵詞所在行:
方法一:cat 路徑/檔案名 | grep 關鍵詞
demo:
cat test.log | grep "http" # 回傳test.log中包含http的所有行
方法二:grep -i 關鍵詞 路徑/檔案名 (與方法一效果相同,不同寫法而已)
demo:
grep -i "http" ./test.log # 回傳test.log中包含http的所有行(-i忽略大小寫)
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/63214.html
標籤:Linux
上一篇:簡單安裝配置samba服務器
