From: Dino Vliet on
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 


From: jomat on
Quoting Dino Vliet <dino_vliet(a)yahoo.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&nbsp;
>
>
>

Use paste. Like this:
paste -d\ filea fileb >filec

-d is the delimiter, in this case a space, per default a tab.

Example:
% 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


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/20100403135752.12875unx9m0zrcxs(a)copete.de
From: Eduardo M KALINOWSKI on
On 04/03/2010 07:09 AM, Dino Vliet wrote:
>
> 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.
>

man paste

--
For people who like that kind of book, that is the kind of book they will like.

Eduardo M KALINOWSKI
eduardo(a)kalinowski.com.br

From: John Hasler on
Dino Vliet writes:
> 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.

man join
--
John Hasler


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/87fx3cka6t.fsf(a)thumper.dhh.gt.org
From: Jomat on
Quoting Dino Vliet <dino_vliet(a)yahoo.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&nbsp;

Use paste. Like this:
paste -d\ filea fileb >filec

-d is the delimiter, in this case a space, per default a tab.

Example:
% 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



--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/20100403135614.19635tkjdve8p6fy(a)copete.de