更新时间:2022-02-22 09:33:32
有很多方法,但这个很简单:
There are a number of approaches but this one is pretty simple:
$content = Get-Content file.txt
$content | Foreach {$_.TrimEnd()} | Set-Content file.txt
您可能需要调整 Set-Content cmdlet 上的 Encoding
参数,以获得所需编码(Unicode、ASCII、UTF8 等)的文件输出.
You may need to tweak the Encoding
parameter on the Set-Content cmdlet to get the file output in the encoding you want (Unicode, ASCII, UTF8, etc).