比赛后SED打印N线
我有一个包含以下行的文件:
some junk
in here
log number 1
line1, data, here
line2,data,here
line3,data,here
and so on
some other
junk
log number 2
line one, some,data
line two, some,data
line three, blablabla
我想在 n-th-th 匹配日志编号...
行之后匹配和打印大约一百行。 此解决方案有效,但我不想在我的sed命令中键入100 ns。
另外/log。*\ n(。*\ n){2}/gm
(匹配后打印2行)在 Regex101 ,但在我的终端上不匹配\ n
)。
我使用Arch Linux和GNU SED 4.8版。
I have a file containing these lines:
some junk
in here
log number 1
line1, data, here
line2,data,here
line3,data,here
and so on
some other
junk
log number 2
line one, some,data
line two, some,data
line three, blablabla
I want to match and print about hundred lines after n-th match of log number ...
lines.
this solution works, but I don't want to type a 100 Ns in my sed command.
Also /log.*\n(.*\n){2}/gm
(printing 2 lines after match) works on regex101 but not on my terminal (sed doesn't match \n
).
I use arch linux and GNU sed version 4.8.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样的事情不起作用吗?
如果您只需要在比赛结束后打印100行,则应该全部需要。
Does something like this not work?
If you just need to print 100 lines after the match, it should be all you need.