0

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

itemnum contains:

ItemNumber
1201
1221
1320
1340
1410

and items contains:

Item
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:

ItemNumber:Item
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
2

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.