0

I have two files each containing hexadecimal numbers one on each line. The two files have the same number of numbers (hence the same number of lines).

I'd like to combine the two files into one but have the numbers displayed side by side, in two columns. So

file A has:

a1
a2
a3

file B has:

b1
b2
b3

I'd like a file that looks like:

a1 b1
a2 b2
a3 b3

Is there a way do do this? join looks like a candidate, but I've been playing around with it, and I can't get it to work. (Join seems to work on the premise of keys and sorted values.)

rici
  • 219,119
  • 25
  • 219
  • 314
Bitdiot
  • 1,456
  • 1
  • 16
  • 28
  • why bash? I'm pretty sure it's not hard to do using `read`, but it's extremely easy e.g. in python. I always encourage people to use the right tools for the right job, and bash is not the tool of choice for string processing, imho. – Marcus Müller Jun 01 '15 at 15:53
  • Well, it started out as a bash script. I'd like the whole script to stay in one language than mixing it. It's just a helper script to help in testing and development. It's not gonna be used anywhere outside my personal bin. – Bitdiot Jun 01 '15 at 15:59

1 Answers1

8

Use paste:

paste A B

That will separate the lines from A and the lines from B with a tab character. If you want them separated with a space instead, use

paste -d' ' A B
rici
  • 219,119
  • 25
  • 219
  • 314