cat ../logs/catalina.out | grep -A1000 字符 
文件passwd中查找包含root的后1000行

B是前n行,A是后n行
A for after
B for before

例:  查看字符 maxAge在文件中前5行  和后5行

cat application.yml |grep -A5 -B5 maxAge


在文件的最后两千行中查看字符1805311612362110的前100 和后100行

tail -2000 ../logs/catalina.out|grep -n -A100 -B100 "1805311612362110"




搜索文件中指定字符的最后一个所在的行数

搜索出文件中所有匹配的,然后通过tail命令只打引出最后一行,即得到反向的第一个。

grep -n 'something' file | tail -n 1
例: grep -n "新增合同result:" ../logs/catalina.out |tail -n 1
155397:新增合同result:{"subCode":200,"message":"true","value":{"contractId":1805161558052665},"code":200}





GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:23 天前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐