Windows等效的Unix tail命令[关闭]

我正在寻找至关于Unix'tail'的命令,它容许我在写入时查看日志文件的输出。 工具


#1楼

Windows资源工具包工具包中提供了tail命令和许多其余命令。 oop


#2楼

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

这不是完美的,有时会重复。 .net

用法: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

#3楼

你能够把尾巴做为Cygwin的一部分。 code


#4楼

我用过Tail For Windows 。 固然不如使用优雅 token

tail
可是,你正在使用Windows。 ;)


#5楼

我建议安装相似GNU Utilities for Win32的东西。 它最受欢迎,包括尾巴。 ip

相关文章
相关标签/搜索