This morning I found myself in the need of removing all white lines in a file of more than 12.000 lines.
Since it’s a white line, you can’t use find&replace in the GUI of notepad… you’ll need something to replace and a white line isn’t something; it’s nothing.
So here’s the PowerShell solution 🙂
1 |
(Get-Content d:\temp\MyFile.ps1) | ? {$_.trim() -ne ""} | Set-Content d:\temp\MyFile.ps1 |