linux系统中,可以用grep查询匹配字段的前后n行:
#过滤匹配字段"test123"行的前后10行
grep -10 'test123' all.log
grep -C 10 'test123' all.log
#过滤匹配字段"test123"行的前10行
grep -B 10 'test123' all.log
#过滤匹配字段"test123"行的后10行
grep -A 10 'test123' all.log
查询grep结果的前后n行
于 2021-12-30 11:42:29 首次发布