I have a log file that looks that looks like the example below:
[hh:mm:ss] LINE 1 GOES HERE
LINE 2 GOES HERE
LINE 3 GOES HERE
LINE 4 GOES HERE
[hh:mm:ss] LINE 5 IS HERE
I'm looking for a way to format this file somewhat like this
[hh:mm:ss] LINE 1 GOES HERE LINE 2 GOES HERE LINE 3 GOES HERE LINE 4 GOES HERE
[hh:mm:ss] LINE 5 GOES HERE
Is there any easy way to do this in PowerShell or CMD.exe ? Any help is appreciated!
Here's what I've come up with so far:
$path = "---path to file----"
Get-Content "$path" | Where { $_.trim() -ne ""} | Set-Content "$path"
This only moves lines up if there is an empty line above, but doesn't really move empty lines behind the original line.