【发布时间】:2014-08-01 17:47:49
【问题描述】:
我有一个包含行的文件,如下所示:
some strings here class="batch2010" some more strings here click-here
<about 20-30lines here>
some strings here class="batch2006" some more strings here click-here
<about 20-30lines here>
some strings here class="NA" some more strings here click-here
<about 20-30lines here>
some strings here class="batch2010" some more strings here access-denied
<about 20-30lines here>
我想打印包含以下内容的行:
class="batch2010"
但不是:
access-denied
在同一行,然后打印文件中的下 10 行。
除了编写一个很长很复杂的shell脚本之外,还有其他方法吗?
【问题讨论】:
-
1) 下一行中的访问被拒绝且符合条件的行呢? 2)在一次出现的后续行中的 10 行中的几条符合条件的行怎么样(分别打印每个或直到块中最后一个符合条件的最后 10 行或仅部分直到下 10 行而不是新的出现,...)?
-
@NeronLeVelu 在接下来的 10 行中出现 access-denied 行的可能性为零。因此,它会自动互斥。