I am looking for a way to compare two files at a key level (id) and display the changes at the column level
file_1.txt
id|description|name|date
1|Row 1|a|2019-06-15 00:20:15:00
2|Row 2|b|2019-06-16 15:18:10:00
3|Row 3|c|2019-06-17 07:02:17:00
4|Row 4|d|2019-06-25 09:00:01:00
5|Row 5|e|2019-06-25 22:00:00:00
file_2.txt
id|description|name|date
1|Row 1|a|2019-06-15 00:20:15:00
2|Row 2|c|2019-06-16 15:18:10:00
4|Row 4|d|2019-06-25 09:00:01:00
5|ROW 5|b|2019-06-25 22:00:00:00
7|Row 7|f|2019-06-17 07:02:17:00
The output should look like:
1|Row 1|a|2019-06-15 00:20:15:001|Row 1|a|2019-06-15 00:20:15:00,Match
2|Row 2|c|2019-06-16 15:18:10:00|Row 2|b|2019-06-16 15:18:10:00No Match
3|Row 3|c|2019-06-17 07:02:17:00,No Match
4|Row 4|d|2019-06-25 09:00:01:004|Row 4|d|2019-06-25 09:00:01:00,Match
5|ROW 5|b|2019-06-25 22:00:00:00|Row 5|e|2019-06-25 22:00:00:00,No Match
7|Row 7|f|2019-06-17 07:02:17:00,No Match
tried using below where file2 is being used as driver file for diaplying the ouput therefore its not printing and ignoring row with id 3 as its not present in file2.txt
awk -F, 'NR==FNR{ arr[$1]=$0; next } { print $0 (arr[$1]==$0?arr[$1]",Match":arr[$1]",No Match") }' OFS=, file1.txt file2.txt
id|description|name|date,Match
1|Row 1|a|2019-06-15 00:20:15:001|Row 1|a|2019-06-15 00:20:15:00,Match
2|Row 2|c|2019-06-16 15:18:10:00,No Match
4|Row 4|d|2019-06-25 09:00:01:004|Row 4|d|2019-06-25 09:00:01:00,Match
5|ROW 5|b|2019-06-25 22:00:00:00,No Match
7|Row 7|f|2019-06-17 07:02:17:00,No Match
Not sure why its only printing records from file1 & file2 when there is a match.
To give some more background on this - I am trying to use this awk command to find differences b/w files and then create a report which basically shows which columns have different values . idealy the end output will look like this
id|Change| Columns
1|No Change|NA
2|Change|name
3|Exists only in file 1|NA
4|No Change|NA
5|Change|description,name
7|Exists only in file 2|NA
Would really appreciate the guidance from all experts out here to achieve this.