user3834663
user3834663

Reputation: 543

Merge two file line by line using awk

I have got two files named file1.txt and file2.txt.

file1.txt :

Tom
Harry
Martin
job
Kevin

file2.txt :

Samson
Edward
Thomas
Wilco

Mergefiles.txt:

Tom
Harry
Martin
job
Kevin
Samson
Edward
Thomas
Wilco

I am using "cat" to merge these files but would like to know if this a good approach or can be done using awk command. pLease help.

cat file1.txt file2.txt > mergefiles.txt

Upvotes: 0

Views: 262

Answers (1)

Scrutinizer
Scrutinizer

Reputation: 9926

cat was created specifically for this purpose. It means to "concatenate" files and that appears to be the operation here, so that is a good approach.


You could get the same behavior with awk :

awk 1 file1.txt file2.txt > concatenatedfiles.txt

But there really is no point in doing that if cat can do the same thing...

Upvotes: 2

Related Questions