Compare two files and mismatch report

Hi
I have two files f1 and f2 and comma separated file.
I need to comapre two files by field by field and not by whole line.
If they match then skip the line from both the files. If they don't match
write the mismatch record from f1 to f3.
Assume both the files are sorted on first field.

f1
a1,a2,a3,a4,a5,a6
b1,b21,b31,b4,b5,b5
c1,c2,c3,c4,c5,c6
 
f2
a1,a2,a3,a4,a5,a6
b1,b2,b3,b4,b5,b6
c1,c2,c3,c4,c51,c61
d1,d2,d3,d4,d5,d6
 
The Output f3
b1,b21,b31,b4,b5,b6
c1,c2,c3,c4,c5,c6

I don't want to compare line by line , this may be required to tuke the data in some field.
I am just looking for Perl or unix script, how should I proceed about this.

Thanks
Dgmm

grep -vf f2 f1

gives the result you show in the example

Hi
I want to compare for each line and each field of that line.
Read the first line
split the line to different fields.
Compare
f1.first field with f2.first field
f1.second field with f2.second field
and so on
if any of the field mismatch then
write the f1 record to f3.

Complete the loop till end of file f1.

Can some once interpret this in Perl or awk.

This is what I want.
By the way the grep command didn't work in my shell.

Thanks
Dgmm

Hi, dgmm.

Welcome to the forum.

I could not get the grep to work, either.

On the other hand, I don't see where this line in f3 comes from:

b1,b21,b31,b4,b5,b6

Is that a typo? ... cheers, drl

I don't understand why you say that you don't want to compare line by line. The steps which you listed will only yield matching records if all fields are identical, which means the lines are identical. If any fields differ, the lines will differ.

Or is there something you neglected to mention about the data in the fields? For example, is whitespace insignificant? Are the fields actually numbers and leading zeroes should not affect a numeric comparison? Is there something that could lead to unidentical lines matching when handled on a field by field basis?

Regards,
Alister

hi alister/drl
You have understood correctly why I am not interested need to compare whole line.

I mis typed the input field.
Yes there might be a field which numeric
so I will compare by lpadding at that time.
So I don't want to compare whole line.

f1
a1,a2,a3,a4,a5,a6
b1,b21,b31,b4,b5,b6
c1,c2,c3,c4,c5,c6
 
f2
a1,a2,a3,a4,a5,a6
b1,b2,b3,b4,b5,b6
c1,c2,c3,c4,c51,c61
d1,d2,d3,d4,d5,d6
 
The Output f3
b1,b21,b31,b4,b5,b6
c1,c2,c3,c4,c5,c6

Please let me know how to read each line , parse it and compare till end of file.

Thanks
Dgmm