extract nth line from file using batch script

December 15, 2010 at 04:27:07
Specs: Windows XP
hi,
i wanted to extract a nth line from a file using batch scripts.

@echo off

set LINES=0

for /f "tokens=* delims=eol" %%I in (123.txt) do (

set /a LINES+=1
IF LINES==6 (
echo %%I >> value1.txt
exit /b
)
)

i tried this but thi sis not working. could anyone suggest a way to hav eit done.


See More: extract nth line from file using batch script

Report •


#1
December 15, 2010 at 04:34:32
@echo off > newfile & setLocal enableDELAYedeXpansion

set N=
for /f "tokens=* delims= " %%a in (myfile) do (
set /a N+=1
if !N! equ 3 >> newfile echo.%%a
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
December 15, 2010 at 05:29:27
thanks dude

Report •

Related Solutions


Ask Question