回复 2# happy886rr
type test.txt^|findstr /n .*好奇怪 后面那个}被过滤了,稍动下你的这段- @echo off&setlocal enabledelayedexpansion
- set "str=李四"
- for /f "tokens=1* delims=:" %%a in ('type test.txt^|findstr /n /i /c:"!str!"') do (set #%%a=1)
- for /f "tokens=1* delims=:" %%a in ('findstr /n .* test.txt') do (
- set "str=%%b"
- if not defined gk (
- echo,%%b
- ) else (
- if defined #%%a (echo,%%b)
- if "!str: =!"=="}" (
- echo,}
- set gk=<nul
- )
- )
- if "!str: =!"=="{" (set gk=1)
- )
- pause>nul
复制代码
|