#!/usr/bin/gawk -f # tLoc - Total number of lines of code # trues - Total number of trues in the data set # falses - Total number of falses in the data set # effortFile - The file to write the individual fired efforts too BEGIN{ tLoc = 100; trues = 1; falses = 1; effortFile = "file.txt"; IGNORECASE = 1; FS=OFS=" "; pd=0; pf=0; count=0; effort=0; } NF == 1 || NF == 0{next;} $2 ~ "true" || $2 ~ "yes"{ gsub( /[\(\)]/, "" ); count++; if ( $4 ~ $2 ) pd++; else pf++; effort = effort + exp( $5 ); if ( trues == 0 ) print effort " " 0 >> effortFile; else print effort/tLoc*100 " " pd/trues*100 " " pf/falses*100 >> effortFile; } END{ print effort " / " tLoc; if ( trues == 0 ) pd = 0; else pd = pd/trues * 100;; if ( falses == 0 ) pf = 0; else pf = pf/falses * 100; if ( tLoc == 0 ) effort = 0; else effort = effort/tLoc * 100; print pd "," pf "," effort; }