本帖最后由 meiszp 于 2019-1-21 21:40 编辑
文本里有多行同时包含“BENDE”和“LASTF ”字符串,希望删除首次同时出现这两个字符串的行。
贴个代码- @echo off
- set "filename=test.txt"
- cd.>tmp$
- for /f "tokens=1* delims=:" %%a in ('findstr /n .* %filename%') do (
- echo "%%b"|findstr "LASTF"|findstr "BENDE">nul&& (set n=%%a&goto :next)
- echo.%%b >>tmp$
- )
- :next
- more +%n% %filename% >>tmp$
- move tmp$ %filename%
复制代码
|