Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 24 down vote accepted

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.

share|improve this answer
3  
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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.