linux查看系統日志文件內容:
tail:
// 查看整個日志文件
tail -f log.log
// 查看日志文件的最后xx行:
tail -xxf log.log
// 第1000行開始,查看1000行
cat filename | tail -n +1000 | head -n 1000
cat filename: 查看某個文件的內容
tail -n +x : 從文件的x行開始查看
head -n x: 查看文件的頭x行
cat:
1、顯示整個文件 cat file
2、創建文件 cat > file
3、合並文件 cat file1 file2 > file3
參數:
-n/--number 每行內容加上行號
-b/--n --noneblock 對所有的非空行內容加上行號
--s 合並二個或以上空行為一個空行
實例:
cat -n file1 > file2
將file1的內容加上行號放到file2
cat -b file1 file2 >> file3
將file1和file2的內容加上行號(空行不加)追加到file3
cat /dev/null > /etc/profile
將profile扔進垃圾箱,並賦予空內容