答案一:
- @echo off&setlocal enabledelayedexpansion
- for /f "tokens=1,2 delims=:" %%i in ('findstr /n "abcd" a.txt') do (
- set a=%%i
- set /a a-=1
- for /f "tokens=1,2 delims=:" %%m in ('findstr /n .* a.txt') do if %%m==!a! echo %%n
- echo %%j
- )
- pause
复制代码
答案二:
- @echo off&setlocal enabledelayedexpansion
- for /f "tokens=1,2 delims=:" %%i in ('findstr /n "abcd" a.txt') do (
- set a=%%i
- set /a a-=1
- for /f "tokens=1,2 delims=:" %%m in ('findstr /n .* a.txt') do if %%m==!a! echo %%n
- echo %%j
- set b=%%i
- set /a b+=1
- for /f "tokens=1,2 delims=:" %%x in ('findstr /n .* a.txt') do if %%x==!b! echo %%y
- )
- pause
复制代码
|