Reputation: 63
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
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