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


当前回答

我写了这个批处理脚本。它不像Unix的“尾巴”那么复杂,但希望有人可以添加它来改进它,比如将输出限制在文件的最后10行,等等。如果你确实改进了这个脚本,请发送给我在抢劫~[at]~ gmail.com。

@echo off

:: This is a batch script I wrote to mimic the 'tail' UNIX command.
:: It is far from perfect, but I am posting it in the hopes that it will
:: be improved by other people. This was designed to work on Windows 7.
:: I have not tested it on any other versions of Windows

if "%1" == "" goto noarg
if "%1" == "/?" goto help
if "%1" == "-?" goto help
if NOT EXIST %1 goto notfound
set taildelay=%2
if "%taildelay%"=="" set taildelay=1

:loop
cls
type %1

:: I use the CHOICE command to create a delay in batch.

CHOICE /C YN /D Y /N /T %taildelay%
goto loop

:: Error handlers

:noarg
echo No arguments given. Try /? for help.
goto die

:notfound
echo The file '%1' could not be found.
goto die

:: Help text

:help
echo TAIL filename [seconds]

:: I use the call more pipe as a way to insert blank lines since echo. doesnt
:: seem to work on Windows 7

call | more
echo Description:
echo     This is a Windows version of the UNIX 'tail' command.
echo     Written completely from scratch by Andrey G.
call | more
echo Parameters:
echo    filename             The name of the file to display
call | more
echo    [seconds]            The number of seconds to delay before reloading the
echo                         file and displaying it again. Default is set to 1
call | more
echo ú  /?                   Displays this help message
call | more
echo    NOTE:
echo    To exit while TAIL is running, press CTRL+C.
call | more
echo Example:
echo    TAIL foo 5
call | more
echo    Will display the contents of the file 'foo',
echo    refreshing every 5 seconds.
call | more

:: This is the end

:die

其他回答

在Far Manager中,在文件上按F3进入标准查看器,然后按End键导航到文件末尾。

如果文件更新了,Far Manager将自动滚动它。

尝试UNIX的Windows服务。提供shell, awk, sed等以及尾部。

更新-:不幸的是,截至2019年,该系统不再适用于微软下载中心。

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

我更喜欢TailMe,因为可以在一个窗口(http://www.dschensky.de/Software/Staff/tailme_en.htm)中同时查看几个日志文件

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