Skip to main content
2 of 3
added 778 characters in body
DopeGhoti
  • 79.2k
  • 10
  • 107
  • 141
awk -F, '$2 == "false" {data[$1]=$2 } $2=="true" { if ( data[$1]!="false" ) { data[$1]=$2 } } END { OFS=","; for (item in data) { print item,data[item] }}' input 

To expand the script vertically for explanation:

BEGIN { IFS="," # Set the input separator; this is what -F, does. } $2 == "false" { # For any line whose second field is "false", we data[$1]=$2 # will use that value no matter what. } $2=="true" { # For lines whose second field is "true", if ( data[$1]!="false" ) { # only keep if if we haven't yet seen a data[$1]=$2 # "false" } } END { # Now that we have tabulated our data, we OFS="," # can print it out by iterating through for (item in data) { # the array we created. print item,data[item] } } 
DopeGhoti
  • 79.2k
  • 10
  • 107
  • 141