linux查看日志内容


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扔进垃圾箱,并赋予空内容

tac: 与cat相反的一个命令
echo:输出一段字符


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM