$ awk -F, 'NR==FNR{a[$1,$3]; next} ($3 != "") && (($1,"") in a)' file file 0044f99638140c2eec15aa78eeb41d5e,/Volumes/Somepath4/Somefile3,Uniquecode The above does 2 passes of the file, the first to create an array indexed by the concatenation of the 1st and 3rd fields of your input, and the second to test for the 3rd field being populated and an index consisting of the concatenation of the 1st field and the null string being present in the array and, if so, print that current line.