打印匹配行之后的所有行 [英] print all rows following matched row

查看:87
本文介绍了打印匹配行之后的所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在第n行中匹配模式之后打印所有行,但是忽略匹配行之前的所有行,包括匹配行,这是一个示例:

How can I print all rows after matching pattern in nth row, but ignore all before matched row including the matching row, here is an example :

row1 something in this row
row2 something in this row
row3 something in this row
row4 don't need to match the whole line, something like java String.contains()
row5 something in this row
row6 something in this row
row7 something in this row
row8 something in this row
row9 something in this row
row10 something in this row

我正在寻找在该行中任何地方包含row4的行之后打印行,这可以通过awk或sed或其他方式实现吗?

I'm looking to print lines following the line which contains row4 anywhere in that row, is this possible with awk or sed, or any other way?

输出应为:

row5 something in this row
row6 something in this row
row7 something in this row
row8 something in this row
row9 something in this row
row10 something in this row

我看过类似的问题:

Awk-在匹配的记录之后打印下一条记录

但是我不确定如何适应它以满足我的需求.

But I'm not sure how to adapt it to fit my needs.

推荐答案

如果Perl适合,您可以这样做:

If Perl is fine with you can do:

perl -ne 'print if($f); $f=1 if(/row4/)'

实施中的代码

这篇关于打印匹配行之后的所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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