【发布时间】:2020-04-02 19:32:38
【问题描述】:
$input_path = "d:\txt\*.txt"
$output_file = 'd:\out.txt'
$regex = "\w* (\w\.? )?\w* (was )?[B|b]orn .{100}"
select-string -Path $input_path -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } > $output_file
Powershell 初学者在这里。我希望它遍历特定目录中的所有文件,搜索特定的正则表达式模式并将结果输出到文件中。到目前为止,我已经设法解决了上述问题。我怎样才能让它也输出每个匹配的文件名?
【问题讨论】:
标签: regex powershell select-string