user3753986
user3753986

Reputation: 5

compare 2 files based on 2 fields and give unmatched records using awk

I have 2 csv files with same format.

File 1:

account, desc, user, date
123, savings, 777, 22092014
234, current, 773, 22092014
456, savings, 772, 22092014

File 2:

account, desc, user, date
123, savings, 778, 22092014
765, savings, 779, 22092014

Keys from the files are 1st and 3rd fields from both the files. output should be only the record with modified key from both the files.user for account "123" is changed in second file.

We need only this record to be part of output file

123, savings, 778, 22092014

Upvotes: 1

Views: 1023

Answers (1)

glenn jackman
glenn jackman

Reputation: 246807

awk 'NR==FNR {user[$1]=$3; next} $1 in user && user[$1] != $3' file1 file2
123, savings, 778, 22092014

Upvotes: 1

Related Questions