tags:

views:

81

answers:

3

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 concatenate theses files lines by lines using a bash script in order to obtain :

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

How can I do using a bash script ?

Thank you in advance for your replies.

+10  A: 

You can use paste:

paste file1.txt file2.txt > fileresults.txt
Mark Byers
+5  A: 

Check

man paste

possible followed by some command like untabify or tabs2spaces

Christopher Creutzig
+1  A: 

here's non-paste methods

awk

awk 'BEGIN {OFS=" "}{
  getline line < "file2"
  print $0,line
} ' file1

Bash

exec 6<"file2"
while read -r line
do
    read -r f2line <&6
    echo "${line}${f2line}"
done <"file1"
exec 6<&-