The content below is taken from the original ( Merging and sorting files on Linux), to continue reading please visit the site. Remember to respect the Author & Copyright.
There are a number of ways to merge and sort text files on Linux, but how to go about it depends on what you’re trying to accomplish – whether you simply want to put the content of multiple files into one big file, or organize it in some way that makes it easier to use. In this post, we’ll look at some commands for sorting and merging file contents and focus on how the results differ.
Using cat
If all you want to do is pull a group of files together into a single file, the cat command is an easy choice. All you have to do is type “cat” and then list the files on the command line in the order in which you want them included in the merged file. Redirect the output of the command to the file you want to create. If a file with the specified name already exists, it will be overwritten by the one you are creating. For example: