- @echo off
- setlocal enabledelayedexpansion
- set var1=AAAA
- set var2=BBBB
- for /f "delims=" %%a in (test.txt) do (
- if "%%a"=="%var2%" (
- set n=
- echo,!str!
- set str=
- )
- if not defined n echo,%%a
- if !n!==true set str=!str!%%a
- if "%%a"=="%var1%" set n=true
- )
- pause
复制代码
|