Remove last line from file with Powershell
If you already know that the very last thing of the file is a CRLF you want to get rid of (and you know the encoding too) you can go the quick route: $stream = [IO.File]::OpenWrite(‘foo.txt’) $stream.SetLength($stream.Length – 2) $stream.Close() $stream.Dispose() This is an in-place truncation of the file. It works without reading all the … Read more