Linux tail -f replacement on Windows

Use Get-Content and Get-Item in Powershell

Looking for the tail command on Windows? Get-Content will do the trick. Here’s a link to the command page.

Open PowerShell:

Show the last line/s:

Get-Content C:\inetpub\logs\LogFiles\W3SVC1\u_ex200711.log -Tail 1

Or use get-item

Get-Item -Path .\LineNumbers.txt | Get-Content -Tail 1

Stream the file like tail -f

Get-Content path-to-file -wait

Get-Content C:\inetpub\logs\LogFiles\W3SVC1\u_ex210129.log -wait
Get-Wait in Powershell instead of tail command

Other examples of Get-Content

See first five lines:

Get-Content -Path .\LineNumbers.txt -TotalCount 5

or use a direct path

Get-Content C:\inetpub\logs\LogFiles\W3SVC1\u_ex200711.log -TotalCount 20

Grab a specific line #:

(Get-Content -Path .\LineNumbers.txt -TotalCount 25)[-1]

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.