linux 查看项目日志
cat nohup.out | grep -n30 "approveReportWF()"
tail -fn 50 nohup.out
sudo grep -r "approveReportWF()" nohup.out
grep -r "approveReportWF()" nohup.out
tail -f nohup.out|grep 'test'
查时间段内的日志:
sed -n '/20230320 09:30:*/,/20230320 09:39:*/p' rce-server.log.2023-03-20 | grep "INFO"
tail -f -n 100 catalina.out linux查看日志后100行
日志文件查看指定关键词前后几行命令:
cat x.log | grep 'xxx' -A100 //(A即after,查看x.log 'xxx' 内容后100行)
cat x.log | grep 'xxx' -B100 //(B即before,查看x.log 'xxx' 内容前100行)
查询日志某关键字前后100行
x为日志文件名称
grep -C 100 'error' xxx.log
上面100行:
grep -B 100 'error' x.log
下面100行:
grep -A 100 'error' x.log
统计字符出现数量
cat test_log-2023-1* |grep "test" |wc -l
more [选项] 要查看的文件
more命令会一页一页地显示文件内容。
more log-error-2023-05-22.0.log
more +3 logtest.log
[选项]
+n 从笫n行开始显示。
-n 定义屏幕大小为n行。
+/pattern 在每个档案显示前搜寻该字串(pattern),然后从该字串前两行之后开始显示。
-c 从顶部清屏,然后显示。
-d 提示“Press space to continue,’q’ to quit(按空格键继续,按q键退出)”,禁用响铃功能。
-l 忽略Ctrl+l(换页)字符。
-p 通过清除窗口而不是滚屏来对文件进行换页,与-c选项相似。
-s 把连续的多个空行显示为一行。
-u 把文件内容中的下画线去掉。
more操作 功能说明
空格键 (space) 代表向下翻一页。
Enter 代表向下翻n行,需要定义,默认为1行。
q 代表立刻离开 more ,不再显示该文件内容。
Ctrl+F 向下滚动一屏。
Ctrl+B 返回上一屏。
= 输出当前行的行号。
:f 输出文件名和当前行的行号。
!命令 调用Shell,并执行命令。
V 调用vi编辑器