Reputation: 2480
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
Reputation: 126712
In PowerShell 3 you can the new Tail parameter:
Get-Content file.log -Tail 1000
Upvotes: 4
Reputation: 91825
The PowerShell Community Extensions has Get-FileTail
:
Get-FileTail -Path foo.txt -Count 1000
Upvotes: 3
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