0

I have 2 files, file 1 and file 2 and I want to compare column 1 in file to column 1 in file 2 and have additional column generated with column 2 in file 3 File 1:

9001    Whitby          On
9002    Toronto         On
9003    Scarborough On
9004    Victoria    BC
9005    Vancouver   BC

File 2:

9001   501
9002   502
9003   503
9004   504
9005   505

Output:

501   9001  Whitby          On
502   9002  Toronto         On
503   9003  Scarborough     On
504   9004  Victoria        BC
505   9005  Vancouver       BC
Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227

1 Answers1

0


you could use Miller http://johnkerl.org/miller/doc/

If your files are two TSV the command is

mlr --tsv --implicit-csv-header --headerless-csv-output  join --ul -l 1 -r 1 -j 1 --lp l --rp r -f file1.csv file2.csv

And you have

9001    Whitby  On      501
9002    Toronto On      502
9003    Scarborough     On      503
9004    Victoria        BC      504
9005    Vancouver       BC      505
aborruso
  • 2,618
  • 10
  • 26