How to merge two files line by line in Bash

Viewed 168005

I have two text files, each of them contains an information by line such like that

file1.txt            file2.txt
----------           ---------
linef11              linef21
linef12              linef22
linef13              linef23
 .                    .
 .                    .
 .                    .

I would like to merge theses files lines by lines using a bash script in order to obtain:

fileresult.txt
--------------
linef11     linef21
linef12     linef22
linef13     linef23
 .           .
 .           .
 .           .

How can this be done in Bash?

5 Answers

You can use paste with the delimiter option if you want to merge and separate two texts in the file

paste -d "," source_file1 source_file2 > destination_file

Without specifying the delimiter will merge two text files using a Tab delimiter

paste source_file1 source_file2 > destination_file
Related