w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
PERL Script To Compare 3 CSV Files & Create a New CSV File

You could use 2 joins:

join -t, -j 1 file1 file2 | join -t, -1 2 -2 1 -o
1.1,1.2,1.3,1.4,1.5,2.2 - file3

Explanation:

  • join -t, -j 1 file1 file2: joins the first two files at field 1.
  • join -t, -1 2 -2 1 ... - file3: the previous statement represents now the first file (-). This is joined with the 3rd file.
  • -o 1.1,1.2,1.3,1.4,1.5,2.2: The output order as in your example.




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.