BEGIN { firstout = 1 lastout = 3 } { if (NR <= 9) { if (NR == 6) { noutput = $6 # printf("No. of output units : %d\n",lastout-firstout+1); # printf("old %d\n",noutput); } else { # print $0 } } else { if ( substr($0,1,1) == "#" ) { indx = 0 printf("\n"); pid=$1; print $0 tmax = -1e99.0 max = -1e99.0; max2=max; } else { for (i = 1; i<=NF; i++) { if ($i > tmax ) { tmax = $i; tmaxpos = i; } } getline; for (i = 1; i<=NF; i++) { if ($i > max ) { max2 = max; maxpos2 = maxpos; max = $i; maxpos = i; } else { if ($i > max2 ) { max2 = $i; maxpos2 = i; } } } # print tmaxpos,maxpos,max,max2 if (tmaxpos==maxpos) {#correct class f="class"maxpos; #cp print "1 "max" "pid >>f; }else{ f="class"maxpos; #fp print "0 "max" "pid >>f; f="class"tmaxpos; #fn print "1 0 "pid >>f; } } } }