EN
Bash - join multiple files
3
points
In this article, we would like to show you how to join multiple files using Bash.
Quick solution:
cat file_1.txt file_2.txt file_3.txt > output.txt
Alternative solution
In this section we join multiple files using cat
command to read files contents one by one and >>
operator to write out them. It is good to prepare place for merged file, so rm
command is used also.
Practical example:
rm "/path/to/output.txt"
cat "/path/to/file_1.txt" >> "/path/to/output.txt"
cat "/path/to/file_2.txt" >> "/path/to/output.txt"
cat "/path/to/file_3.txt" >> "/path/to/output.txt"