小编Eru*_*aki的帖子

从文本文件中打印两行之间的数据(仅当“范围结束”存在时)

我需要解析一个文件,我希望在两个特定行之间打印一段数据。从“范围开始”到“范围结束”,但前提是“范围结束”存在。

如果源文件是:

[This is the start] of some data 
this is information
this is more information
This is does not contain the ending required

[This is the start] of some other data
this is info I want
this is info I want
[This is the ending I was looking for]
Run Code Online (Sandbox Code Playgroud)

它应该打印:

[This is the start] of some other data
this is info I want
this is info I want
[This is the ending I was looking for]
Run Code Online (Sandbox Code Playgroud)

使用 grep 我已经能够找到我需要的数据并向上打印,但只能通过固定数量的行。 …

grep sed text-processing files

0
推荐指数
1
解决办法
1661
查看次数

标签 统计

files ×1

grep ×1

sed ×1

text-processing ×1