Tuesday, July 21, 2015

Merge Multiple Files in Unix/Linux

What I found following examples are the quickest and kind of cleanest way to combine and aggregate few files to one separate file.

sed -n wfile.merge file1 file2
Or:
awk '{print > "file.merge"}' file1 file2
Or:
sh -c 'cat file1 file2 > file.merge'

Note: If you want to run the above on multiple file you can select all of the in one go for example all the txt file in the current directory:


sed -n wfile.merge *.txt

No comments:

Post a Comment