0

There is a problem given at link-https://stackoverflow.com/questions/61784456/combine-two-csv-files-based-on-common-column-using-awk-or-sed

Join command works wonderful, however I have a question on top of it.

If you don't get the key in file 2, that line is not printed-- I want to print that line too from file 1 even if match is not found in file 2.

Example

sample1.csv
43980970,2,ABC
44768809,1,XYZ
67889901,3,PQR

sample2.csv
43980970,Y
67889901,N

I run command : join -t, -o 1.1 1.2 1.3 2.2 -1 1 -2 1 sample1.csv sample2.csv
o/p
43980970,2,ABC,Y
67889901,3,PQR,N

Instead I want output as:
43980970,2,ABC,Y
44768809,1,XYZ,
67889901,3,PQR,N

Can some one please guide me

R S
  • 1
  • Assuming GNU join, `-a1` parameter to `join` (add unpaired lines from first file) should do it. – Amadan Jan 15 '22 at 13:49

0 Answers0