Languages
[Edit]
EN

Bash - join multiple files

3 points
Created by:
Khloe-Kaiser
578

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"

 

See also

  1. Bash - split file into parts (by size)

Alternative titles

  1. Bash - concat multiple files
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join