How to compare data in two flat files and update them?

Hi All,

I am giving an example similar to the problem I have.
I have two data files of 10 columns each in which fields are delimited by comma(,). I need to compare compare the two files using the uniq col(col3). If there are any records in file1 and are not in file2 then I have check the value for col4 of those records from a database table, if its success then I have to include those records in file2 and have to change the value of col6 to "updated".

Can you please give me an idea how to implement in a shell script.

your help will be greatly appreciated.

Thanks in Advance.
Raju

Not very sure on the requirement but have you tried the UNIX 'join' command?

Could you please suggest me how to replace two fields in a flat file which contains more than 40 fields.

If I use sed by searching for the strings there may be a chance that the same string occurs in other fields also.

If I use awk I explicitly metion the rest of the 38 fields.

Please suggest me how to deal with this.

Thanks in advance
Raju

to change the 2-nd and the 5-th fields in the file "myFile"
nawk '{$2="foo"; $5="bar"; print}' myFile