Compare files and share output from both files

hi all,

Thanks to all for your great help...

I have a scenario that I have two files (file1 & file2). I need to compare two files entire row by row and share the output if any discrepancies within two files.

File1:

DB1|TB1|C1,C3
DB2|TB2|C1,C2
DB3|TB3|C1,C2,C3,C4

File2:

DB1|TB1|C1,C2,C3
DB2|TB2|C1,C2
DB3|TB3|C1,C3
DB4|TB4|C1,C2,C4

Output should be:

DB1|TB1|C2  --email content should be "missing in file1 or new column added in file2
DB3|TB3|C2,C4 -- email content "remove C4,C2 from file 1" 
DB4|TB4|C1,C2,C4  -- missing in file1

IN short, we need to compare two files and share difference/missing items from these two files. Comparison should be ROW by ROW.

You explained your problem quite inconsistently, so a few questions first:

I take it your files are of the form

key,value

where "key" is something like "DB1|TB1|" and "value" is everything after that. You search for every of these keys, compare the differences in the corresponding "value"s and record these differences, yes?

If so: can there be more than one line for each key in each file? i.e.

file1

DB1|TB1|C1,C2

file2

DB1|TB1|C1
DB1|TB1|C2

and would this result in "no difference" or in something else?

Then, are the entries in "value" all separated by commas and can that be used consistently as a delimiter?

bakunin

Thanks for your response.

The requirement is to compare two files (which has "database name"|"Tablename"|"Column1,column2,column3") in this pattern, but there might be a mismatch in number of columns in any one of the file..

Output should be like the missing column names should get displayed with respective db & tables.

File 1

database1|table1|column1,column2,column3
database2|table2|column1,column3
database3|table3|column1,column2,column3,column4

File 2:

database1|table1|column1,column3
database2|table2|column1,column2,column3
database3|table3|column1,column3,column4

if any column name is missing in any one of the file for the database|table names, then it should display the changes by stating both file contents (db|tab|column names) and send an email.