我正在寻找Unix 'tail'命令的等效,这将允许我观察日志文件的输出,而它正在被写入。
当前回答
在Far Manager中,在文件上按F3进入标准查看器,然后按End键导航到文件末尾。
如果文件更新了,Far Manager将自动滚动它。
其他回答
如果你根本不想安装任何东西,你可以用标准的Windows命令“构建你自己的”批处理文件。这里有一些关于如何做到这一点的建议。
1)使用find /c /v "" yourinput。文件,获取输入文件中的行数。输出如下所示:
---------- T.TXT: 15
2)使用for /f,解析此输出以得到数字15。
3)使用set /a,计算需要跳过的标题行数
4)使用for /f "skip=n"跳过头部行,回显/处理尾部行。
如果我有时间,我将构建这样一个批处理文件,并将其发布回这里。
编辑:tail.bat
REM tail.bat
REM
REM Usage: tail.bat <file> <number-of-lines>
REM
REM Examples: tail.bat myfile.txt 10
REM tail.bat "C:\My File\With\Spaces.txt" 10
@ECHO OFF
for /f "tokens=2-3 delims=:" %%f in ('find /c /v "" %1') do (
for %%F in (%%f %%g) do set nbLines=%%F )
set /a nbSkippedLines=%nbLines%-%2
for /f "usebackq skip=%nbSkippedLines% delims=" %%d in (%1) do echo %%d
任何人对使用批处理命令(见下文)的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
在Far Manager中,在文件上按F3进入标准查看器,然后按End键导航到文件末尾。
如果文件更新了,Far Manager将自动滚动它。
我建议为Win32安装GNU实用程序。它有最喜欢的,包括尾巴。
在Windows资源工具包工具包中可以使用tail命令和许多其他命令。
推荐文章
- 在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中的任何命令行运行它