我正在寻找Unix 'tail'命令的等效,这将允许我观察日志文件的输出,而它正在被写入。
当前回答
任何人对使用批处理命令(见下文)的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
其他回答
你可以得到尾巴作为Cygwin的一部分。
下载tail命令,这是微软自己提供的Windows Server 2003资源工具包工具的一部分。
有相当多的选择,但他们都有更高级的功能缺陷。
GnuWin32尾巴是错误的(α β γ) -像-f只是不工作。 UnxUtils尾部似乎更好(-f工作,但-pid似乎不是,-n但不是——lines=n失败与-f),但似乎是一个死亡的项目。 Cygwin是一个巨大的丑陋的混乱,可能只需要使用DLL和coreutils包-但仍然存在问题,如pid不能与本机win32进程一起工作。
我最近使用了Mtail,它似乎工作得很好。这就是上面提到的像baretail一样的GUI类型。
DOS没有尾部指令;你可以在这里下载GNU tail和其他GNU工具的Windows二进制文件。
推荐文章
- 如何从命令行在windows中找到mysql数据目录
- 在没有事件源注册的情况下写入Windows应用程序事件日志
- 无法在Windows上从/usr/local/ssl/openssl.cnf加载配置信息
- GIT克隆在windows中跨本地文件系统回购
- 如何运行一个PowerShell脚本而不显示窗口?
- PowerShell:仅为单个命令设置环境变量
- 为什么这个Windows批处理文件只执行第一行,而在命令shell中执行所有三行?
- 环境变量存储在Windows注册表的哪里?
- 有一个好的Valgrind Windows的替代品吗?
- Windows和Linux上的c++编译:ifdef开关
- 如何验证批处理文件中是否存在一个文件?
- XAMPP -端口80被PID 4的“无法打开进程”使用!12
- 为什么git在Windows下记不住我的密码
- Git克隆/拉不断冻结在“存储密钥在缓存?”
- 有没有替换Windows (Visual C)的unistd.h ?