The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 07-17-2008
jeffpas jeffpas is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 60
Does anybody want to take a crack at this?
My slow brain is simply not understanding.

If for example:

awk 'BEGIN{FS=OFS=","}
NR==FNR{a[$1]=$0; next}
a[$1]{$0=$0 RS a[$1]}{print}' file2 file1

Adds a line to file1 if the first field matches in both files.
How do you only print the line if say, fields1, 2, 5, and 6 match both files?
And of course, I would have to reverse that (i.e., only add the lines to file1 if fields 1, 2, 5, and 6 are NOT matched between file1 and file2)

Obviously the first FNR line is file2, a[$1] being the first field.
The second line then matches a[$1] and appends a record to the output of file1.

Thanks much for any assistance.