eXpLoIt
eXpLoIt

Reputation: 63

Most efficient way to delete first N lines from a log file

I have logs enabled for a lot of basic scripts I am running and I need to clear out those logs from time to time.

What is the most efficient way to delete first N lines from a log file in PowerShell?

Upvotes: 5

Views: 8823

Answers (1)

Moerwald
Moerwald

Reputation: 11254

You could try the Skip parameter of Select-Object

Get-Content logfile.log | Select-Object -Skip 10 | Out-File clearedLogfile.txt

Upvotes: 8

Related Questions