I'm trying to combine two different files, one called itemnum and another called items.

itemnum contains:


and items contains:

Lobby Furniture
Ballroom Specialties
Poolside Carts
Formal Dining Specials
Reservation Logs

I want to use join here right? So that the output looks like this:

1201:Lobby Furniture
1221:Ballroom Specialties
1320:Poolside Carts
1340:Formal Dining Specials
1410:Reservation Logs

I can't even figure out how to get them to join, let alone add the :

I tried join itemnum items > prodinfo, but that just gives me an empty file.

  • I guess you've misunderstood the join command. Check linux.die.net/man/1/join – ott-- Aug 30 '16 at 21:19
  • 1
    The join command joins files on a common key (which your files do not appear to have) - if you just want to join successive lines from each file side-by-side you can use the paste command instead e.g. paste -d\: itemnum items > prodinfo – steeldriver Aug 30 '16 at 21:20
  • How would I add a colon? Using -d? – user2120893 Aug 30 '16 at 21:21

As mentioned : Join requires a key column and isn't the right command for what you are looking to do. Confirmed as @steeldriver says

paste -d : file1.txt file2.txt > filemerge.txt

Your Answer

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

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