data() { # target, feature, weight, filter cat< /tmp/w gawk -F, 'Pass==1 {sum[$1] += $3*$4} Pass==2 { printf("%s,%5.3F,%5.1f\n", $0,$3*$4,int(100*$3*$4)/sum[$1])}' \ Pass=1 /tmp/w Pass=2 /tmp/w