25 Nov 2013 @ 10:55 AM 

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

(Get-Content d:\temp\MyFile.ps1) | ? {$_.trim() -ne ""} | Set-Content d:\temp\MyFile.ps1
Posted By: Jeff Wouters
Last Edit: 25 Nov 2013 @ 10:55 AM

EmailPermalink
Tags
Categories: DuPSUG, PowerShell



 Last 50 Posts
 Back
Change Theme...
  • Users » 1
  • Posts/Pages » 323
  • Comments » 461
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.

Contact



    No Child Pages.

Speaking



    No Child Pages.

Health Check



    No Child Pages.