Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

This question already has an answer here:

Standard cat concatenates files line by line (row by row, if you will). I find myself needing a horizontal cat command more and more often recently; i.e. a command that takes a list of files and concatenates them horizontally, column by column. So far I’ve used ad-hoc workarounds but I’d like to know if there exists a good solution for this.

To clarify, consider the following comparison between cat and hcat of two files:

$ cat a.dat 1.dat
a b
c d
1 2
3 4
$ hcat -s ' ' a.dat 1.dat
a b 1 2
c d 3 4

(Unlike for cat we need to specify a separator since by convention UNIX files don’t have a column separator at the end.)

share|improve this question

marked as duplicate by Anthon, Mat, slm, Hauke Laging, jasonwryan Jun 26 '13 at 18:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

So, I'm doing it wrong?… – Iszi Dec 13 '12 at 14:23
@Iszi In the C++ chat I actually wrote “in before longcat is long” when posting the link, to prevent precisely that :p – Konrad Rudolph Dec 13 '12 at 14:26
Ah, longcat! That's the search term I should have been looking for! – Iszi Dec 13 '12 at 14:28
Longcat is quite vertical though… and long. – poke Dec 13 '12 at 14:32

1 Answer 1

up vote 29 down vote accepted

This sounds like a job for paste:

paste -d ' ' a.dat 1.dat


a b 1 2
c d 3 4
share|improve this answer
Perfect, thanks. That was easier than anticipated. – Konrad Rudolph Dec 13 '12 at 10:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.