我正在寻找Unix 'tail'命令的等效,这将允许我观察日志文件的输出,而它正在被写入。
当前回答
你可以得到尾巴作为Cygwin的一部分。
其他回答
如果你想使用Win32端口的一些Unix实用程序(而不是安装Cygwin),我推荐Win32的GNU实用程序。
重量比Cygwin轻,更轻便。
如果你使用PowerShell,那么这是有效的:
Get-Content filenamehere -Wait -Tail 30
把Stefan的评论贴在下面,这样大家就不会错过了
PowerShell 3引入了-Tail参数,只包含最后x行
我一直用Baretail在Windows中跟踪。它是免费的,而且很不错。
你可以得到尾巴作为Cygwin的一部分。
我写了这个批处理脚本。它不像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
推荐文章
- 在Sublime Text 2中使用Ctrl+D进行多个选择时,我如何跳过匹配?
- #定义WIN32_LEAN_AND_MEAN具体排除了什么?
- 最好的轻量级web服务器(只有静态内容)的Windows
- npm犯错!错误:EPERM:操作不允许,重命名
- 崇高的文本从命令行
- 如何保持Python脚本输出窗口打开?
- 使用.bat文件检查文件夹是否存在
- 如何查看Windows库(*.lib)的内容
- 在Windows中删除大文件夹最快的方法是什么?
- NPM卡住给出相同的错误EISDIR:对目录的非法操作,读取错误(本机)
- Windows 10环境变量太大
- 如何使用Windows命令行更改目录
- 如何在NERDTree中显示隐藏文件(以句点开始)?
- Objective-C for Windows
- “注册”一个.exe,这样你就可以从Windows中的任何命令行运行它