computing
  • 6

Extract Nth Line From File Using Batch Script

  • 6

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.

Share

1 Answer

  1. @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

    • 0