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 20 ...
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忽略大小寫)