所以,基本上我想要一个批处理文件来读取 .txt。问题是每次将新行写入 .txt 时,批处理文件都需要更新
@echo off
set "pc=%1"
FOR /F "delims=:" %%A IN ('findstr /N .* "%pc%"') DO set "zeilen=%%A"
type %pc%
set /A zeilen1=%zeilen%
:loop
if not %zeilen% == %zeilen1% (
set "line="
set zeilen2=%zeilen% - 1
for /f %%a in ('more/e +%zeilen2% ^< %pc%') do (
if not defined line set "line=%%a"
)
echo %line%
set /A zeilen+=1
)
FOR /F "delims=:" %%A IN ('findstr /N .* "%pc%"') DO set "zeilen1=%%A
goto loop
我也无法使用 type 命令(第 9-13 行),因为我不想只刷新整个 .txt 最后一行。
抱歉我的英语很差
谢谢
要启动批处理,您需要执行以下操作调用batch.cmd txtname.txt
最佳答案
基本的 tail 命令可以这样写。感谢 @dbenham 在 DosTips.com 上的初步解决方案
@echo off
call :Loop <"tailme.txt"
exit
:Loop
set "line="
set /p "line="
if defined line (
echo %line%
) else (
pathping -q 1 -p 300 localhost >nul
)
goto :loop
关于batch-file - 批量.txt阅读器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52920525/