Computing Staff
  • 0

How To Copy Only 10 First Lines From A Text

  • 0

Hi to all,

i would like to copy only 10 first lines from a text and copy into another existing file.

my project is:

1-get last update files from a directory => done in java
2-concatenate files from this directory into on file =>done in java
3-delete some specific lines from the concatenated file=>done in batch file
4-i want to copy the 10 first line from a file in batch file

could any one help me please.
i was using dos command in 1988 with an old pc but i don’t remenber today.
thank you

Share

1 Answer

  1. :: ==========================================
    ::
    :: firstten.bat Sat 12-02-2011 2:43:03.56
    @echo off & setLocal enableDELAYedeXpansion
    set N=
    for /f “tokens=* delims= ” %%a in (myfile) do (
    set /a N+=1
    if !N! gtr 10 goto :done
    >> existing.txt echo.%%a
    )
    :done

    • 0