Is there a Linux command like cat
that joins files with the same number of lines horizontally?
Asked
Active
Viewed 2.2k times
32

Gilles 'SO- stop being evil'
- 829,060
-
It took me a LONG time to find this question! It seems "horizontal" is the only way to find an answer to this problem. All the other "duplicates" when I searched for "concatenate columns with awk", etc., only led to database join with awk. – Josiah Yoder Dec 07 '22 at 15:08
2 Answers
46
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.

l0b0
- 51,350
-
5As seen in the example above, the default delimiter is TAB... For no delimiter:
paste -d '\0' t1 t2
– Peter.O Mar 11 '11 at 00:10 -
-