常用linux日志查询命令

原文及更多文章请见个人博客:http://heartlifes.com

1.查看实时日志:

tail -f nohup.out

2.分页查看所有日志:

cat nohup.out | more

4.分页查看前N行日志:

tail -n 1000 nohup.out | more

5.查看实时日志并检索关键字:

tail -f nohup.out | grep "关键字"

6.检索日志,并显示该条日志的前后N行记录:

cat nohup.out | grep -n -B10 -A10 "关键字"

7.查看日志,从第1000行开始,显示500行:

cat nohup.out | tail -n +1000| head -n 500
### 8.查看日志,显示1000行到1500行:
```shell
cat nohup.out | head -n 1500| tail -n +1000

9.删除包括关键词的行:

sed -i '/关键词/d' nohup.out
原文地址:https://www.cnblogs.com/heartlifes/p/6971014.html