Concatenate multiple PDF files into one PDF file

For this purpose we need ghostscript, but basically this software comes pre-installed in most linux distribution.

So to concatenate multiple PDFs (file1.pdf, file2.pdf, file3.pdf), into one file (output.pdf), simply run this:

$ gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf file1pdf file2.pdf file3.pdf

Yes, it’s a long command, I know. To change the output paper size we can replace “a4” with “legal” for US Legal or “letter” for US Letter.