Concatenate text files with Windows command line, dropping leading lines

前端 未结 12 918
心在旅途
心在旅途 2020-11-30 18:03

I need to concatenate some relatively large text files, and would prefer to do this via the command line. Unfortunately I only have Windows, and cannot install new software.

12条回答
  •  情话喂你
    2020-11-30 18:39

    Use the FOR command to echo a file line by line, and with the 'skip' option to miss a number of starting lines...

    FOR /F "skip=1" %i in (file2.txt) do @echo %i
    

    You could redirect the output of a batch file, containing something like...

    FOR /F %%i in (file1.txt) do @echo %%i
    FOR /F "skip=1" %%i in (file2.txt) do @echo %%i
    

    Note the double % when a FOR variable is used within a batch file.

提交回复
热议问题