- @echo off
- setlocal enabledelayedexpansion
- set fileName=a.txt
- for /f "tokens=1 delims=:" %%i in ('findstr /n "《数学的历史》" %fileName%') do (
- set lineKeyword=%%i
- )
- if !lineKeyword! equ 1 (
- echo,
- ) else if !lineKeyword! equ 2 (
- set /p linePri=<%fileName%
- echo,%linePri%
- ) else (
- set /a lineSkip=lineKeyword-2
- call :next !lineSkip!
- )
- pause
- goto :eof
-
- :next
- for /f "skip=%1" %%i in (%fileName%) do (
- echo,%%i
- goto :eof
- )
复制代码
|