How to Concatenate Multiple Files in Linux

To combine multiple files into a single file in linux you want to use the 'cat' command. This command stands for concatenate and will combine however many files into a new or existing file.

Say you have fileA and fileB and you want to combine their content into a new file called fileC. To do this you would run the cat command:

fileA fileB > fileC

Bam, fileA and fileB still exist, but now you created fileC which is a combination of the two. This is especially useful when combining multiple scripts into one. for example, when developing a web app you may have multiple JavaScript files. This is great for development because it allows you to keep track of everything better. However, for production, this is not ideal as each individual file requires an individual http request. That is slow. Instead, the JavaScript files should be concatenated into a single file which will then create only one http request.

You can also use cat to quickly view the contents of a file.

cat fileA

will quickly display the content of fileA to your screen.

Combining multiple files into a single file in linux is easy!