Merge files in Linux
Introduction
To learn what kinds of Linux files there are, and what else besides merging you can do with them, read the article «Files in Linux»
Merging files
Files in Linux can be merged in various ways. In this article you will learn how to do it with the commands cat and echo
cat
To merge the file one with the file two just run
cat one two
You can merge several files at once.
Consider three files
one
,
two
,
three
with the following contents
one
Cool bookstore: Book24
two
Best hotels: Booking.com
three
Official Samsung Store: Samsung
Let's merge them and check the result - it will appear in the console just as it did with the two files
cat one two three
Cool bookstore: Book24
Best hotels: Booking.com
Official Samsung Store: Samsung
Now let's merge the files into one new file big
cat one two three > big
vi big
Cool bookstore: Book24
Best hotels: Booking.com
Official Samsung Store: Samsung
To the new file big we can append the file one
cat big one
Cool bookstore: Book24
Best hotels: Booking.com
Official Samsung Store: Samsung
Cool bookstore: Book24
echo
The file two can be written to the end of the file one
echo $(<two) >> one
Merging .pdf files
This section has been moved to a separate article
«Merging .pdf files»
Article author: Andrei Olegovich