BEGIN{FS=OFS=","} { for(i=1;i<=(NF-2);i++) { if (index("rely,data,cplx,time,stor,virt,turn,acap,aexp,pcap,vexp,lexp,modp,tool,sced", $i)!=0) { if(i<(NF-2)) { printf("%s,",$i) } else { printf("%s\n",$i) } } } }