联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
Originally posted by lxmxn at 2006-12-12 00:50: 还有一个问题,就是如果a.txt里面有空行(直接回车)的话,那么就会出错,批处理提示: 已经达到最大的 setlocal 递归层。 不知道这个问题怎么解决?
@echo off set num=0 for /f "delims=" %%i in ('findstr /n .* test.txt') do ( set /a num+=1 set "str=%%i" setlocal enabledelayedexpansion echo 第 !num! 行: !str:*:=! endlocal ) pause
@echo off (for /f "delims=" %%i in ('more ^< "%~f1" ^| findstr /n .*') do ( set "str=%%i" setlocal enabledelayedexpansion echo;!str:*:=! endlocal ))>test.out fc "%~f1" test.out pause
@echo off if "%1"=="" %0 "%~f0" (for /f "delims=" %%i in ('more ^< %1 ^| findstr /n .*') do ( set "str=%%i" setlocal enabledelayedexpansion echo;!str:*:=! endlocal ))>test.tmp type test.tmp echo --------- more < %1 > %1.tmp fc %1.tmp test.tmp pause
@echo off if "%~1"=="" ( %0 "%~f0" goto :eof ) (for /f "usebackq delims=" %%i in (`more ^< %1 ^| findstr /n .*`) do ( set "str=%%i" setlocal enabledelayedexpansion echo;!str:*:=! endlocal ))>"%~dp1test.tmp" type "%~dp1test.tmp" echo ------------------ more < "%~1" > "%~1.tmp" fc "%~1.tmp" "%~dp1test.tmp" pause hxuan?表ー: 2006-12-13 18:28
@echo off setlocal disabledelayedexpansion set num=0 for /f "delims=" %%i in ('findstr /n .* test.txt') do ( set /a num+=1 set "str=%%i" setlocal enabledelayedexpansion echo 第 !num! 行: !str:*:=! endlocal ) pause