I am new to shell scripting and want to use awk to parse a file. I have a log file which looks something like this log.txt where each record name(A,B,C) is shown twice.
A,10.10.250.2,Compliant
A,10.10.250.2,Compliant
B,10.10.250.3,NonCompliant
B,10.10.250.3,Compliant
C,10.10.250.4,NonCompliant
C,10.10.250.4,NonCompliant
I want to merge both the record where record name is same, something like this:
A,10.10.250.2,Compliant, NA,Compliant
B,10.10.250.3, NonCompliant,Yes,Compliant
C,10.10.250.4, NonCompliant,No,NonCompliant
The 4th Column is “NA” when both last column values are Compliant, “Yes” when NonCompliant and “Compliant” and “No” when it is NonCompliant and NonCompliant. 5th column is the last value of second record.
I am trying something like this which is not correct, needs some help
awk -F "," '{if ($1 == $1) print NR}' log.txt