Find the difference in specific field

Hi All,

Seeking for your assistance to get the difference of field1 and field2 and output all the records if there's a difference. please see below scenario.

file1.txt
250|UPTREND FASHION DESIGN,CORP.|2016-04-04 09:36:13.991257
74|MAINSTREAM BUSINESS INC.|2016-04-04 09:36:13.991257
36|HOMEWORLD SHOPPING CORP.|2016-03-30 12:50:13.50646

file2.txt
250|UPTREND FASHION DESIGN,CORP.|2016-04-04 09:33:13.991257
74|MAINSTREAM BUSINESS INC.|2016-04-04 09:35:13.991257
 I tried this diff file1.txt file2.txt | grep "<" | awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}' but the problem is it will check all the records, all i want is the field1 and field2 check only.

Please advise,

Thanks,

---------- Post updated at 10:15 AM ---------- Previous update was at 09:56 AM ----------

I already solve the problem using this code

awk 'NR==FNR {exclude[$1$2];next} !($1$2 in exclude)' file2.txt file1.txt

Thank you!

Thank you for

  • trying and solving yourself!
  • sharing the solution for the benefit of others.