Skip to main content
Post Made Community Wiki by don_crissti
Post Undeleted by don_crissti
Post Deleted by don_crissti
Source Link
don_crissti
  • 85.7k
  • 31
  • 234
  • 263

Sounds like you want to join on first three fields. You should then change the first two delimiters, join on the new 1st field and then restore the delimiters:

join -t, -j1 -a1 -a2 -o 0 1.2 1.3 2.2 2.3 -e " MISSING" \ <(sed 's/, /\x02/;s/, /\x02/' 1.txt) <(sed 's/, /\x02/;s/, /\x02/' 2.txt) \ | sed 's/\x02/, /g' 

returns

1, abc, 123, 456, 789, 000, 000 2, lmn, 123, 456, 789, MISSING, MISSING 3, pqr, 123, 456, 789, 000, 000 9, opq, 123, MISSING, MISSING, 000, 000