user2470170
user2470170

Reputation: 2480

accessing logs using Powershell

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.

Upvotes: 3

Views: 458

Answers (3)

Shay Levy
Shay Levy

Reputation: 126712

In PowerShell 3 you can the new Tail parameter:

Get-Content file.log -Tail 1000

Upvotes: 4

Roger Lipscombe
Roger Lipscombe

Reputation: 91825

The PowerShell Community Extensions has Get-FileTail:

Get-FileTail -Path foo.txt -Count 1000

Upvotes: 3

Kyle Muir
Kyle Muir

Reputation: 3925

Does this help?

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

Get-Content loads all the info from log.txt into memory, this is then passed to Select-Object which will return you the last 1000 items, in this case it will return the last 1000 lines of text.

Hope this helps.

Upvotes: 2

Related Questions