快速Unix命令在一个文件的中间显示特定行? [英] Quick unix command to display specific lines in the middle of a file?

查看:149
本文介绍了快速Unix命令在一个文件的中间显示特定行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试调试的问题与服务器和我唯一的日志文件是一个20GB的日志文件(没有时间戳即使!为什么人们使用的System.out.println()日志记录?在生产中?!)

Trying to debug an issue with a server and my only log file is a 20GB log file (with no timestamps even! Why do people use System.out.println() as logging? In production?!)

,我发现,我想看看,行347340107文件的区域。

Using grep, I've found an area of the file that I'd like to take a look at, line 347340107.

除了做这样的事情。

head -<$LINENUM + 10> filename | tail -20

...这将需要通过第一3.47亿行日志文件的阅读,是有一个快速简便的命令,将转储线347340100 - 347340200 (例如)到控制台?

... which would require head to read through the first 347 million lines of the log file, is there a quick and easy command that would dump lines 347340100 - 347340200 (for example) to the console?

更新我完全忘了,grep的可打印围绕一个比赛......这工作得很好的背景。谢谢!

update I totally forgot that grep can print the context around a match ... this works well. Thanks!

推荐答案

与GNU的grep的,你可以只说

with GNU-grep you could just say

grep --context=10 ...

这篇关于快速Unix命令在一个文件的中间显示特定行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆