tags:

views:

32

answers:

1

I found find and replace text answer from another question and hope that someone have the answer to my question.

how to use powershell to remove extra spaces at end of line in a text file?

Thanks in advance

Swanl

+2  A: 

There are a number of approaches but this one is pretty simple:

$content = Get-Content file.txt
$content | Foreach {$_.TrimEnd()} | Set-Content file.txt

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).

Keith Hill