Linux command tail -f on Windows in PowerShell

0
(0)

Linux tail is part of the GNU Core Utilities (Coreutils), the tail command is not included in Windows, but can use in PowerShell. It is a collection of basic command line commands that come with most Linux OS.

First and foremost, tail is used to output the end of a (text) file, or to restrict the output of a Linux command to a certain area. The tail command is related to the head command and the cat and less commands. These Linux commands all serve one purpose of outputting the contents of text files.

Linux tail with PowerShell on Windows

As used on Linux tail with the -f (–follow) option to follow the update of a log file in real time, but on Windows there is no tail command. For this Windows has the PowerShell command Get-Content, to track a log file followed in real time, new lines that are written to the log file can also be displayed continuously under Windows.

PowerShell Get-Content -Wait -Tail

On Windows, the Linux tail command does not exist. For this, Windows has the PowerShell command Get-Content, with the option -Wait -Tail a log file can be followed in real time. New lines that are written to the log file can also be displayed continuously under Windows.

PS C:\> Get-Content C:\inetpub\logs\LogFiles\W3SVC1\20230227.log -Wait -Tail 10

  The update is stopped when you click in the PowerShell window, the update stays in mark mode, the update is continued with hit Escape.

This example tracks the IIS log file in real time and outputs it to Windows 10 or Windows 11 PowerShell.

On Linux the equivalent command is tail -f and on Windows it would look like tail -f C:\inetpub\logs\LogFiles\W3SVC1\20230227.log

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Leave a Reply

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