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()}

1 comment

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

Leave a comment

Your email address will not be published. Required fields are marked *

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