Remove White Spaces From A text File Using Powershell

To remove white spaces from a text file using powershell use:

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

One Reply to “Remove White Spaces From A text File Using Powershell”

  1. [System.IO.File]::WriteAllText(
    “FILE_NAME”,
    ([System.IO.File]::ReadAllText(“FILE_NAME”) -replace ‘\s’)
    )

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.