Windows equivalent of the ‘tail’ command [duplicate]

IF you have Windows PowerShell installed (I think it’s included since XP) you can just run from cmd.exe:

Head Command:

powershell -command "& {Get-Content *filename* -TotalCount *n*}"

Tail Command:

powershell -command "& {Get-Content *filename* | Select-Object -last *n*}"

or, directly from PowerShell:

Get-Content *filename* -TotalCount *n*
Get-Content *filename* | Select-Object -last *n*

update

PowerShell 3.0 (Windows 8 and higher) added Tail command with alias Last.
Head and First aliases to TotalCount were also added.

So, commands can be re-written as

Get-Content *filename* -Head *n*
Get-Content *filename* -Tail *n*

Leave a Comment