29

Is there a Linux command like cat that joins files with the same number of lines horizontally?

43

paste may do the trick.

% cat t1 
a
b
c
c
d
f
g
% cat t2 
h
i
j
k
l
m
n
% paste t1 t2 
a       h
b       i
c       j
c       k
d       l
f       m
g       n

At least some of the time, you don't need to have a "key" to concatenate the lines.

3
  • 5
    As seen in the example above, the default delimiter is TAB... For no delimiter: paste -d '\0' t1 t2 – Peter.O Mar 11 '11 at 0:10
  • will this work for files that are gigabytes in size? – SARose Apr 26 '17 at 23:30
  • @SARose I don't know. Give it a try and leave a comment about the results. – Bruce Ediger Apr 27 '17 at 0:15
4

join should do the trick - You just need to prefix the lines with an identical ID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy