: !/bin/sh awk -F'|' ' function mround2(cst) { if ( match(cst,"\...5$") > 0 ) cst += 0.001 return sprintf("%0.2f", cst) } function mround4(cst) { if ( match(cst,"\.....5$") > 0 ) cst += 0.00001 return sprintf("%0.4f", cst) } { if ( $4 != "CDR" ) #if ( $4 != "CHARGE_DESC" ) next orgcost = $14 orgtot += orgcost newcost = $15 newtot += newcost print orgcost " " newcost } END { print "" print "tot = " orgtot " " newtot printf("tot = %0.2f %0.2f\n", orgtot, newtot) printf("mround tot = %0.2f %0.2f\n", mround2(orgtot), mround2(newtot)) } '