我正在寻找Unix 'tail'命令的等效,这将允许我观察日志文件的输出,而它正在被写入。


当前回答

我建议为Win32安装GNU实用程序。它有最喜欢的,包括尾巴。

其他回答

使用Windows PowerShell,您可以使用:

Get-Content <file> -Wait

任何人对使用批处理命令(见下文)的DOS CMD尾部感兴趣。

它不是完美的,有时台词会重复。

用法:tail.bat -d 尾巴,蝙蝠-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

我在这里的答案中没有看到Log Expert。

它是可定制的,非常适合处理日志文件。到目前为止,它对我来说是最好的Windows图形日志查看器。

不幸的是,该软件已不再可用。你可以在archive.org上读到它。

我一直用Baretail在Windows中跟踪。它是免费的,而且很不错。

DOS的类型工作方式类似于*nux的cat,尽管就像cat一样,它也会转储整个文件,所以它不是真正的tail,但它将在必要时可用,而无需下载/安装真正的tail替代品。