Powershell Select-String -context

时间:2017-08-29 17:23:00

标签: arrays powershell select-string

我有一个文本文件,我需要读取模式之间的行并包含模式匹配。

示例:

Attributes
att 1
att 2
col 1
col 2

Attributes
att 1
att 2
pos 1

Attributes
set 1
set 2
att 1

现在我有:

$Attributes = Get-Content att.txt | Select-String "Attributes" -Context 0,3

将属性和接下来的3行返回到数组条目中。但是,我希望这是动态的,而不是具体的接下来的3行。我希望所有的行直到下一个属性模式。

0 个答案:

没有答案