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="FS="," # 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] } }