How to merge multiple files into one in Linux?

A quick way of merging multiple files into one via your Linux terminal is to use the cat command.

Let's say that you have 3 log files and you would like to copy the content of those files into 1 log file containing all entires. You could use the following command:

cat file1.log file2.log file3.log > file.log

You would end up with a file called file.log that contains the content of the 3 log files.

If you wanted to delete the files as well you could use the following:

cat file1.log file2.log file3.log > file.logs ; rm -f file1.log file2.log file3.log

Hope that this helps!

© 2020 DevDojo LLC. All rights reserved.