Skip to content

Instantly share code, notes, and snippets.

@Stuart-Moore
Created August 5, 2016 11:08
Show Gist options
  • Save Stuart-Moore/bd401f7860a50840466d882ab18022b7 to your computer and use it in GitHub Desktop.
Save Stuart-Moore/bd401f7860a50840466d882ab18022b7 to your computer and use it in GitHub Desktop.
$output = @()
$plineblank = $false
$tline = ''
$reader = [System.IO.File]::OpenText("C:\full\path\to\testfile.txt ")
while($null -ne ($line = $reader.ReadLine())) {
if ($line -eq '' -and $pline -ne '' ){
$output += $tline
$tline = $null
} else {
$tline = $tline+"`n"+$line
}
$pline = $line
}
$output += $tline
$reader.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment