tags:

views:

11738

answers:

16

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.

+9  A: 

You can get tail as part of Cygwin.

David Dorward
+2  A: 

Installing cygwin might be overkill, but it gives you all the linux utilities.

Mark Ransom
+4  A: 

I've used Tail For Windows. Certainly not as elegant as using

tail
but then, you're using Windows. ;)

Jake
I don't find your insinuation that the elegancy of a third party tool depends on the OS it runs on very helpful. Certainly having a grahical version of "tail" is no more or less elegant as the command line alternatives other answers are proposing.
Dave Van den Eynde
Having a graphical version IS less elegant because there is overhead in opening the application, graphically selecting the file, and manually having to turn on monitoring. On the command line, it's just a few keystrokes. Is what I meant. Tangentially, no, I would not describe Windows as 'elegant'.
Jake
+12  A: 

I'd suggest installing something like GNU Utilities for Win32. It has most favourites, including tail.

Ryan Duffield
I don't know why, but I can't download from the HTTP download link.
Thomas Owens
+1  A: 

If you want to use Win32 ports of some Unix utilities (rather than installing Cygwin), I recommend GNU utilities for Win32.

Lighter weight than Cygwin and more portable.

Grant Wagner
+5  A: 

I've always used Baretail for tailing in Windows. It's free and pretty nice.

Edit: for a better description of Baretail see this question

Instantsoup
You "forgot" to specify that Beretail has an annoying splash screen, and that if you want to remove it you have to pay.
Sorin Sbarnea
If by "forgot" you mean "have no recollection of a splash screen because it obviously never bothered you", then yes, I "forgot"!
Instantsoup
+4  A: 

Try Windows Services for UNIX. Provides shells, awk, sed, etc. as well as tail.

Dave
+1  A: 

I use these and I don't have to cygwin my box. http://unxutils.sourceforge.net/

kenny
+1  A: 

If you do not want to install anything at all you can "build your own" batch file that does the job from standard Windows commands. Here are some pointers as to how to do it.

1) Using find /c /v "" yourinput.file, get the number of lines in your input file. The output is something like:

---------- T.TXT: 15

2) Using for /f, parse this output to get the number 15.

3) Using set /a, calculate the number of head lines that needs to be skipped

4) Using for /f "skip=n" skip the head lines and echo/process the tail lines.

If I find the time, I will build such a batch file and post it back here.

Philibert Perusse
Windows is such a joy. I was into Unix when DOS first "came up" with subdirectories, and was abhorred to see them using \ for the path separator instead of / (as God intended). That was a portent to all the incompatible BS that came out of MS ever since. Does MS even have a grep?
xcramps
+3  A: 

There are quite a number of options, however all of them have flaws with more advanced features.

  • The Windows Server 2003 Tools provides a simple tail that can be downloaded with the Resource Kit Tools. It is too limited in many respects (locks followed file, lacks many options like --pid), however will do for the basic task of tracking a file.

  • GnuWin32 tail is buggy (α β γ) - things like -f just plain don't work.

  • UnxUtils tail seems better (-f works, but --pid seems not to, -n but not --lines=n fails with -f), but appears to be a dead project.

  • Cygwin is a big ugly mush, could perhaps just use the DLL and coreutils package - but still has problems like --pid not working with native win32 processes.

gz
+11  A: 

If you use PowerShell then this works:

Get-Content filenamehere -Wait
Alex
Learned something new. Thanks!
fatcat1111
Actually this is not dynamic
Xinxua
It's dynamic for me.
jrm82
+1  A: 

I prefer TailMe because of the possibility to watch several log files simultaneously in one window: http://www.dschensky.de/Software/Staff/tailme_en.htm

Benedikt Eger
+1  A: 

GnuWin32 tail:

tail -f --retry file

tail -F file

both use the retry option, this helps with the -f not working

+4  A: 

Anybody interested in a DOS tail using batch commands (see below) Its not prefect and lines sometime repeat.

usage: tail.bat -d tail.bat -f -f

@echo off
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
rem tail.bat -d <lines> <file>
rem tail.bat -f <file>

rem ****** MAIN ****** 
IF "%1"=="-d" GOTO displayfile
IF "%1"=="-f" GOTO followfile

GOTO end

rem ************ 
rem Show Last n lines of file
rem ************ 

:displayfile
SET skiplines=%2
SET sourcefile=%3

rem *** Get the current line count of file ***
FOR /F "usebackq tokens=3,3 delims= " %%l IN (`find /c /v "" %sourcefile%`) DO (call SET find_lc=%%l)

rem *** Calculate the lines to skip
SET /A skiplines=%find_lc%-!skiplines!

rem *** Display to screen line needed
more +%skiplines% %sourcefile%

GOTO end

rem ************ 
rem Show Last n lines of file & follow output
rem ************ 

:followfile
SET skiplines=0
SET findend_lc=0
SET sourcefile=%2

:followloop
rem *** Get the current line count of file ***
FOR /F "usebackq tokens=3,3 delims= " %%l IN (`find /c /v "" %sourcefile%`) DO (call SET find_lc=%%l)
FOR /F "usebackq tokens=3,3 delims= " %%l IN (`find /c /v "" %sourcefile%`) DO (call SET findend_lc=%%l)

rem *** Calculate the lines to skip
SET /A skiplines=%findend_lc%-%find_lc%
SET /A skiplines=%find_lc%-%skiplines%

rem *** Display to screen line when file updated
more +%skiplines% %sourcefile%

goto followloop

:end
+1  A: 

install MKS tool kit.. so that you can run all unix commands in windows.

tail -f is the command.

kk
A: 

Bare tail is a good option for windows users.

sandeep
http://stackoverflow.com/questions/187587/looking-for-a-windows-equivalent-of-the-unix-tail-command/187604#187604
Jørn Schou-Rode