Concatenate text files with Windows command line, dropping leading lines

James picture James · Mar 19, 2010 · Viewed 317k times · Source

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.

type file1.txt file2.txt > out.txt

allows me to almost get what I want, but I don't want the 1st line of file2.txt to be included in out.txt.

I have noticed that more has the +n option to specify a starting line, but I haven't managed to combine these to get the result I want. I'm aware that this may not be possible in Windows, and I can always edit out.txt by hand to get rid of the line, but is there a simple way of doing it from the command line?

Answer

ghostdog74 picture ghostdog74 · Mar 19, 2010
more +2 file2.txt > temp
type temp file1.txt > out.txt

or you can use copy. See copy /? for more.

copy /b temp+file1.txt  out.txt