A while ago, I needed a terminal solution to merge different PDF files into a single file.

You can use the tool pdfunite from the poppler package to do this.

First, you need to install it. This depends a little on the platform you are using:

Install on mac

$ brew install poppler

Install on Ubuntu Linux

$ sudo apt install poppler-utils

After the install, you can inspect how it works by running it's help command:

$ pdfunite -?
pdfunite version 20.11.0
Copyright 2005-2020 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011 Glyph & Cog, LLC
Usage: pdfunite [options] <PDF-sourcefile-1>..<PDF-sourcefile-n> <PDF-destfile>
  -v             : print copyright and version info
  -h             : print usage information
  -help          : print usage information
  --help         : print usage information
  -?             : print usage information

So, we can easily combine PDF files now using:

$ pdfunite pdf1.pdf pdf2.pdf combined_pdf.pdf

Thanks to StackOverflow for helping me finding this out :)