1. 查询 debug.log 文件中存在 "接收mq消息" 的字符串
grep "接收mq消息:" ./debug.log
将筛选出来的日志数据,输出到/home/boost/a.txt 文本中:
cat nohup.out | grep "2022-01-19" >> /home/boost/a.txt
2. 查看 debug.log文件中有 2022-01-12 10:35 字符串的日志,并进一步查询存在 "进入断电逻辑"的字符串
cat debug.log | grep "2022-01-12 10:35" | grep "进入断电逻辑"
3. 查看动态变化的日志(查看实时变化的 debug.log 日志,并显示前面1000行的日志数据)
tail -1000f debug.log
4. 查看动态变化的日志(实时查看包含 2022-01-22 字符串的日志 )
tail -f debug.log | grep 2022-01-22
5. 查看动态变化的日志(实时查看包含 最大线程数 字符串前后10行的日志 )
tail -f debug.log | grep -C 10 最大线程数
6. 查看动态变化的日志(实时查看包含 最大线程数 字符串 后10行的日志 )
tail -f debug.log | grep -A 10 最大线程数