PowerShell v5 + -NoNewline Set-Content ( Add-Content Out-File).
, .NET Framework , , .
Caveat: -NoNewline , , , ( ).
, , -NoNewline , , , , , - :
(('one', 'two', 'three') -join "`n") + "`n" | Set-Content -NoNewLine $filePath).
: .
: ForEach-Object < <28 > ; (PSv3 +, - Get-Content -Raw, -Raw, ( ) PSv2 ):
Get-ChildItem . *.xml -Recurse |
ForEach-Object {
$filePath = $_.FullName
(Get-Content -Raw $filePath) -replace '&# 8211;', 'β' `
-replace '&# 160;', ' ' `
-replace '&# 8221;', '"' |
Set-Content -NoNewline $filePath
}
:
TheMadTechnician , $filePath script ForEach-Object -PipelineVariable (-pv):
Get-ChildItem . *.xml -Recurse -PipelineVariable ThisFile |
ForEach-Object {
(Get-Content -Raw $ThisFile.FullName) -replace '&# 8211;', 'β' `
-replace '&# 160;', ' ' `
-replace '&# 8221;', '"' |
Set-Content -NoNewline $ThisFile.FullName
}
, , PipelinVariable, $, .
$ThisFile Get-ChildItem (-) .
,
-PipelinVariable , , , .