从日志文件中删除前N行的最有效方法

eXp*_*oIt 2 powershell powershell-3.0

我已经为我正在运行的许多基本脚本启用了日志,我需要不时清除这些日志.

在PowerShell中从日志文件中删除前N行的最有效方法是什么?

Moe*_*ald 6

你可以尝试Skip参数Select-Object

Get-Content logfile.log | Select-Object -Skip 10 | Out-File clearedLogfile.txt
Run Code Online (Sandbox Code Playgroud)