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:
xxxxxxxxxx
1
cat file_1.txt file_2.txt file_3.txt > output.txt
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:
xxxxxxxxxx
1
rm "/path/to/output.txt"
2
3
cat "/path/to/file_1.txt" >> "/path/to/output.txt"
4
cat "/path/to/file_2.txt" >> "/path/to/output.txt"
5
cat "/path/to/file_3.txt" >> "/path/to/output.txt"