Answer the question
In order to leave comments, you need to log in
BAT. How to copy a part of a file starting from a certain line?
Data.txt
Вступление.
На несколько строк.
Заголовок нужных данных
Иванов
Петров
Сидоров
Васечкин
Иванов
Петров
Сидоров
Васечкин
@echo off
set file=1.txt
set word=искомое слово
for /f "tokens=1 delims=[]" %%n in ('find /i /n "%word%" ^<"%file%"') do set /a "$n=%%n+1"
for /f "tokens=1* delims=[]" %%a in ('find /n /v "" ^<"%file%"^|findstr /b "\[%$n%\]"') do echo.%%b
for /f "tokens=1 delims=[]" %%n in ('find /i /n "%word%" ^<"%file%"') do set /a "$n=%%n"
:doagain
set $flag1=1
set /a $n=%$n%+1
for /f "tokens=1* delims=[]" %%a in ('find /n /v "" ^<"%file%"^|findstr /b "\[%$n%\]"') do (echo.%%b & set $flag1=2)
if $flag1 leq 2 goto doagain
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question