原格式输出,不能输出空行
@echo off
for /l %%n in (3,1,90) do call :need %%n
pause
exit
:need
set /a line=%1-1
for /f "skip=%line% delims=" %%i in ('more test.txt') do (
echo %%i
goto :eof
)
可以输出空行,但每行不能含有和行号相同的“行号:”字符,不能输出“!、:”字符及同行中“!、:”字符包围的字符
@echo off
setlocal EnableDelayedExpansion
for /l %%n in (31,90) do call :need %%n
pause
exit
:need
set /a line=%1-1
for /f "skip=%line% delims=" %%i in ('findstr /n .* "test.txt"') do (
set "str=%%i"
set "str=!str:%1:=!"
if not "!str!" == "" (echo !str!) else echo.
goto :eof
)
[
Last edited by zh159 on 2007-4-27 at 10:49 AM ]