bat脚本读取最后几行

@echo off
rem 好像读取的时候忽略了空的行,就是说会少一些没有内容的行
set counter=0
for /f  %%a in (d:\testjxs.log) do (
set /a counter+=1
)


setlocal enabledelayedexpansion

set skip=%counter%
::skip为跳过行数
set loop=10
::loop为输出行数
set filename=d:\testjxs.log
::filename为所要读取的文件
set counter=0

set opt="skip=%skip% tokens=*"
for /f %opt% %%i in (%filename%) do (
 if !counter! geq !loop! goto wayout
 set /a counter+=1
 rem echo %%i
 set abc=%%i
 set log=!log!%%i
)
echo %log%
:wayout

你可能感兴趣的:(bat)