Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A Windows equivalent of the Unix tail command [closed]

Tags:

windows

tail

I'm looking for the equivalent of the Unix 'tail' command that will allow me to watch the output of a log file while it is being written to.

like image 642
Liam Avatar asked Oct 09 '08 14:10

Liam


People also ask

What is the Windows equivalent of tail?

Traditionally tail has been used to view the bottom X number of lines from a log file. While Windows doesn't have a standalone utility to do what tail does, we do have the Get-Content PowerShell cmdlet which happens to have a tail parameter.

Is there a tail command in PowerShell?

The Tail command is popular in the Unix language and it is used to retrieve the specific number of lines from the end of the document or the log files. PowerShell doesn't have the command with the same name but from the PowerShell v3. 0 onwards, PowerShell has added -Tail parameter in the Get-Content cmdlet.

How do you tail a file in Windows PowerShell?

Open it with notepad $PROFILE. Then in the text document, create a new function: function Tail ($path) { Get-content -tail 15 -path $path -wait } This way you can access the function each time you start PowerShell. This should be the accepted answer.

What is tail in Unix command?

On Unix-like operating systems, the tail command reads a file, and outputs the last part of it (the "tail"). The tail command can also monitor data streams and open files, displaying new information as it is written. For example, it's a useful way to monitor the newest events in a system log in real time.


1 Answers

If you use PowerShell then this works:

Get-Content filenamehere -Wait -Tail 30 

Posting Stefan's comment from below, so people don't miss it

PowerShell 3 introduces a -Tail parameter to include only the last x lines

like image 73
Alex Avatar answered Oct 27 '22 08:10

Alex