【发布时间】:2019-03-13 08:37:55
【问题描述】:
我需要删除/替换写在更多行上并且在文本行之间有空白行的特定文本。
例如:
some text
text 1
other text
text 1
我需要删除:
other text
text 1
结果将是:
some text
text 1
现在我有这个:
(Get-Content file.txt) -notmatch "other textrntext 1" | Out-File file.txt
【问题讨论】:
-
不一样。我需要删除一个有空行的部分。
-
您错过了显示到目前为止的代码。您可能会阅读以下帮助 How do I ask a good question? 和 How to create a Minimal, Complete, and Verifiable example。
-
该示例应该可以帮助您入门...使用带有 -raw 参数的 get-content cmdlet,然后您可以在 select-string 的 -pattern 参数中使用 \r\n 来匹配换行符。正如 Olaf 所说,您应该提供一些代码。
-
现在我有这个:(Get-Content file.txt) -notmatch "other text
rntext 1" |输出文件 file.txt 。它不是这样工作的,我使用“rn”的方式有问题。
标签: powershell text-manipulation