更新时间:2023-11-14 23:21:52
只输出额外的文本,例如
Just output the extra text e.g.
(Get-Content $fileName) |
Foreach-Object {
$_ # send the current line to output
if ($_ -match "pattern")
{
#Add Lines after the selected pattern
"Text To Add"
}
} | Set-Content $fileName
您可能不需要额外的n",因为 PowerShell 将为您行终止每个字符串.
You may not need the extra ``n` since PowerShell will line terminate each string for you.