联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
@echo off&SetLocal ENABLEDELAYEDEXPANSION :::::::::::ReadLine2.Bat:::::::::::::::::: if "%1"=="" (goto --help) else (set file=%1) if not exist %file% goto :eof if "%2"=="" ( for /f "tokens=1* delims=:" %%a in ('findstr /n .* "%file%"') do echo/%%b goto :eof ) else ( set args=%* for %%a in (!args!) do ( if not "%%a"=="%1" (for /f "tokens=1* delims=:" %%b in ('findstr /n .* "%file%"') do ( if "%%b"=="%%a" echo/%%c) ) ) ) goto :eof :--help echo/====================================== echo/本程序段需要带参数才能正常运行 echo/&echo/Usage:&echo/Call ReadLine2 ^<文件名^> ^<读取行号^> echo/&echo/例如:Call ReadLine2 aa.txt 5 7 11 ,将读取aa.txt文件的第5,7,11行 echo/&echo/如果^<读取行号^>没有指定,将读取整个文件的内容 echo/====================================== goto :eof
Originally posted by HUNRYBECKY at 2007-3-20 08:33: lxmxn斑竹怎么一贴发两个地方呀,为了管理方便,建议移到原来的ReadLine1.bat下.谢谢