home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / awk / awk320.zip / SUM.AWK < prev    next >
Text File  |  1990-02-08  |  396b  |  13 lines

  1. # accumulate totals and transactions for each person
  2. # print the transactions in a separate file for each person
  3. # print the total and average when done
  4.  
  5. NF == 2 { a[$1] += $2; b[$1]++
  6.           printf "%-6s %3d %3d %3d\n", $1, $2, a[$1], b[$1] >$1
  7.         }
  8. END     { print ""
  9.           for (i in a)
  10.                 printf "%-6s %3d %6.1f %3d\n", i, a[i], a[i]/b[i], b[i]
  11.         }
  12.  
  13.