
CODE: [Copy to clipboard]若无须考虑连接符号,则可以使用如下演示代码:@echo off
for /f "delims=" %%i in ('findstr /n .* 1.txt') do call :intercept "%%i☆"
pause
goto :eof
:intercept
set str=%1
set "str=%str:~1,-1%"
set "str=%str:*:=%"
if not "%str:~0,4%"=="aaa " echo "%str:~0,-1%"
goto :eof
CODE: [Copy to clipboard]以上代码不直接用 delims=: 是为了防止行首的冒号被抛弃;用 findstr /n .* 的格式是为了不忽略以分号开头的行;给 %%i 加引号是为了对付空格,在 %%i 后加星号,是为了对付空行;第二段代码用 echo 后加了一个点号,也是为了对付空行。总之,用 for 语句处理文本要注意的事项比较多,可视具体文本增删语句的某些部分。@echo off
for /f "delims=" %%i in ('findstr /n .* 1.txt') do call :intercept "%%i☆"
pause
goto :eof
:intercept
set str=%1
set str=%str:~1,-1%
set str=%str:*:=%
if not "%str:~0,4%"=="aaa " echo.%str:~0,-1%
goto :eof
CODE: [Copy to clipboard]注意要加上参数 /i 来忽略大小写。@echo off
findstr /b /i /v /c:"Rem " 1.txt>2.txt
start 2.txt
| 欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) | Powered by Discuz! 2.5 |