# /* vim: set filetype=awk : */ -*- awk -*- BEGIN{ FS=OFS = ","; Data = 1; Rx = 2; Effect = 3; Fields = 3; Exclude = "s0m1mp0ss1blesymb01"; Include = ""; } NR==1 { split(Data,Datas); split(Rx,Rxs); split(Effect,Effects); } function all(a, s,t) { for(i in a) {s = s t $a[i]; t="|"}; return s } { sub( /\#.*/, "") } # cull comments and blanks { gsub(/[ \t]/,"") } /^$/ { next } # blank line, skip NF != Fields { next } # wrong number of fields Exclude && $0 ~ Exclude { next } # ignore this line Include && $0 !~ Include { next } # ignore what you don't want to use { d = all(Datas); # collect lines r = all(Rxs) e = all(Effects); _Effect[d,r] = e; # store values, from data, treated in some way _Datas[d]++; # keep a list of datas _Rx[d,++_Rx[d,0]] = r; # keep a stack of treatments applied to that data } END { for(D in _Datas) report(D) } function report(d, max,i,j,r1,r2) { max=_Rx[d,0]; for(i=1;i<=max;i++) for(j=1;j<=max;j++) if (i != j) { r1=_Rx[d,i]; # want same data, different treatments r2=_Rx[d,j]; print r1, r2,_Effect[d,r1] - _Effect[d,r2] } # print and sort the delta }