Skip to content

Instantly share code, notes, and snippets.

@chrisbrownie
Created February 19, 2016 02:04
Show Gist options
  • Save chrisbrownie/0d812d2f8d3a1ee57863 to your computer and use it in GitHub Desktop.
Save chrisbrownie/0d812d2f8d3a1ee57863 to your computer and use it in GitHub Desktop.
Removes empty lines from a file
$logFile = "$pwd\dns.log"
$newLogFile = "$pwd\dns_cleaned.log"
$sr = New-Object System.IO.StreamReader($logFile)
$sw = New-Object System.IO.StreamWriter($newLogFile)
$line = $sr.ReadLine()
while ($line -ne $null) {
if ($line.trim() -ne "") {
$sw.WriteLine($line)
}
$line = $sr.ReadLine()
}
$sw.flush()
$sw.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment