Ale*_*lex 417
如果您使用PowerShell,那么这适用:
Get-Content filenamehere -Wait -Tail 30
Run Code Online (Sandbox Code Playgroud)
从下面发布Stefan的评论,所以人们不要错过它
PowerShell 3引入了一个-Tail参数,仅包含最后的x行
Rya*_*eld 133
我建议安装类似GNU Utilities for Win32的东西.它最受欢迎,包括尾巴.
小智 23
任何对使用批处理命令的DOS CMD尾部感兴趣的人(见下文).
这不是完美的,有时会重复.
用法: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
Run Code Online (Sandbox Code Playgroud)
gz.*_*gz. 22
有很多选项,但是它们都有更多高级功能的缺陷.
在Windows Server 2003和的工具提供了一个简单的尾巴,可与Resource Kit工具下载.它在许多方面都太有限(锁定后跟文件,缺少像--pid这样的许多选项),但是对于跟踪文件的基本任务也是如此.
尾部的GnuWin32是越野车(α β γ) -比如-f只是简单的不工作.
UnxUtils尾部似乎更好(-f工作,但是-pid似乎没有,-n但不是--lines = n失败了-f),但似乎是一个死的项目.
Cygwin是一个很大的丑陋,可能只是使用DLL和coreutils包 - 但仍然有像--pid不能使用本机win32进程的问题.
Jak*_*ake 18
我用过Tail For Windows.当然不如使用优雅
tail但是,你正在使用Windows.;)
Osc*_*Ryz 14
使用Windows PowerShell,您可以使用:
Get-Content <file> -Wait
Run Code Online (Sandbox Code Playgroud)
Phi*_*sse 12
如果您根本不想安装任何东西,可以"构建自己的"批处理文件,从标准Windows命令执行该任务.以下是关于如何做到这一点的一些指示.
1)使用find/c/v""yourinput.file,获取输入文件中的行数.输出类似于:
---------- T.TXT: 15
Run Code Online (Sandbox Code Playgroud)
2)使用for/f,解析此输出以获得数字15.
3)使用set/a,计算需要跳过的头行数
4)使用for/f"skip = n"跳过头行并回显/处理尾线.
如果我找到时间,我将构建这样一个批处理文件并将其发回此处.
尝试使用Windows Services for UNIX.提供贝壳,awk,sed等以及尾部.
| 归档时间: |
|
| 查看次数: |
445505 次 |
| 最近记录: |