#BEGIN {print "@relation intersection"} BEGIN {IGNORECASE=1; OFS=","} FNR==1 {M=Locs=0; Filenames[FILENAME]++; Files++ } /@attribute/ { M++; if ($2 == "loc") Locs++; if (Locs > 1) { true } else { Want[$2]++; Index[FILENAME,$2]=M; About[$2]=$0 }} END { for(A in About) print Files, A , Want[A] }