3

I'm trying to access a log file which is 55GB and will not open in any editor. I'm trying to get the last 1000 lines from the log using power shell. I'm new to powershell and any help in doing this is greatly appreciated.

4

3 回答 3

4

在 PowerShell 3 中,您可以使用新的 Tail 参数:

Get-Content file.log -Tail 1000
于 2013-06-10T08:56:36.893 回答
3

PowerShell社区扩展具有:Get-FileTail

Get-FileTail -Path foo.txt -Count 1000
于 2013-06-10T08:41:27.200 回答
2

这有帮助吗?

Get-Content '\directory\to\your\log.txt' | Select-Object -last 1000

Get-Content 将 log.txt 中的所有信息加载到内存中,然后将其传递给 Select-Object,它将返回最后 1000 个项目,在这种情况下,它将返回最后 1000 行文本。

希望这可以帮助。

于 2013-06-10T08:40:27.267 回答