Re: shell command or script to combine two files
Quoting Dino Vliet <email@example.com>:
Hi debian people,
I have two files with the same number of rows but different columns.
I want to create one file out of them and am looking for a simple
shell command or shell script to accomplish that.
File 1 has N number of rows and columns X,Y,Z and File 2 has N
number of rows and P,Q,R as columns.The resulting file should have N
number of rows and X,Y,Z,P,Q,R as columns.
1) Is there a simple command in Bash to accomplish this?2) What
would a script to do this look like? Uses Gawk?3) If N=10000000 and
the two files have 45 columns with mixed integer and character
values, what would be the most efficient approach (fastest) and why?
Thanks in advanced
Use paste. Like this:
paste -d\ filea fileb >filec
-d is the delimiter, in this case a space, per default a tab.
% cat filea
1 2 3
a b c
x y z
o p q
% cat fileb
6 7 8
5 6 7
q w e
a s d
% paste -d" " filea fileb
1 2 3 6 7 8
a b c 5 6 7
x y z q w e
o p q a s d