Use Unix JOIN command to merge two files Use Unix JOIN command to merge two files unix unix

Use Unix JOIN command to merge two files


You used the -a option.

-a file_number

In addition to the default output, produce a line for each unpairable line in file file_number.

In addition, the odd overwriting behavior indicates that you have embedded carriage returns (\r). I would examine those fies closely with cat -v or a text editor that doesn't try to be "smart" about Windows files.


Use the correct 'field' separator in your command.

When I changed your data to true csv, and used

join -t, -1 2 -2 2 -a 1 -o 1.2 1.3 2.3 file1.csv file2.csv# ---^^^

I got

123,JohnDoe,DaddyDoe456,BobDylan,DaddyDylan789,BillyJean,DaddyJean

I hope this helps.


If you are doing this command line why not use paste?paste -d, file1 file2 >> file3

the -d arugment is the delimiter