palc
palc

Reputation: 45

pasting files/multiple columns with different number of rows

Hi I was trying to paste multiple files (each with a single column but different number of rows) together. But it did't provide what I was expecting. How to solve that?

paste file1.txt file2.txt paste3.txt ... paste100 > out.txt

input file 1:

A
B
C

input file 2:

D
E

input file 3:

F
G
H
I
J

....... ......

Desired output:

A   D   F
B   E   G
C       H
        I
        J

Would this be same if the files have multiple columns with different number of rows? for example:

file1

A  1
B  2
C  3

file2

D  4
E  5

file3

F  6  %
G  7  &
H  8  #
I  9  @
J  10 ?

output:

A  1  D  4  F  6  %
B  2  E  5  G  7  &
C  3        H  8  #
            I  9  @
            J  10 ?

Upvotes: 0

Views: 350

Answers (1)

gboffi
gboffi

Reputation: 25023

Isn't the default behaviour of paste exactly what you ask?

% paste <(echo "a
b
c
d") <(echo "1
2
3") <(echo "10
> 20
> 30
> 40
> 50
> 60")
a       1       10
b       2       20
c       3       30
d               40
                50
                60
% 

Upvotes: 2

Related Questions