Each join combines two files based on their first field; the -t, tells it to use commas as the field separator (whitespace is the default). This is then sent to cut, which extracts the 1st, 2nd, 6th, and 10th field from each line, again using comma for the field separator (as specified by -d,).$ join -t, file1.txt file2.txt | join -t, - file3.txt | cut -f 1,2,6,1 +0 -d, WSOMQAVPRA05,93.75,34.78,93.13 wsomdavpra03,90.39,69.04,68.85 wsomddvfxa01,39.22,92.44,46.97 wsompapgtw05,49.6,48.77,30.66
Note that join is dependent on the sort field being in the same order in both input files, so you'll need to sort into temp files if this isn't known to be the case. If you are making temp files, though, you can do a sort <filename> | cut -f1,2 -d, > <tempfile> and eliminate the need for the final cut after joining the files, which makes it a bit easier to generalize to different numbers of files.
In reply to Re: Combining Records From Multiple Files based on Common Key Values
by dsheroh
in thread Combining Records From Multiple Files based on Common Key Values
by country1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |