home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / MAWK113.ZIP / mawk113 / msdos / examples / srcstat.awk < prev    next >
Text File  |  1992-12-05  |  723b  |  27 lines

  1. # Ben Myers <0003571400@mcimail.com>
  2.  
  3. # Sum up number, line count, and sizes of SOURCE files in current directory
  4. # run with 
  5. #       bmawk -fsrcsize.awk workfile
  6. # or similar command syntax with your awk program
  7. # where workfile is a work file
  8. BEGIN {
  9. # redirection done by shelled command
  10. # system("dir *.* >workfile")
  11. system("dir *.* >" ARGV[1])
  12. ssize = 0   # size accumulator
  13. slines = 0  # line counter
  14. scount = 0  # obj counter
  15. }
  16. # Now read workfile back in
  17. $2 == "C" || $2 == "H" || $2 == "CPP" || $2 == "HPP" {
  18.     filename = sprintf("%s.%s", $1, $2)
  19.     ssize += $3
  20.     while (getline < filename > 0) {slines++}
  21.     scount++
  22.     }
  23. END {
  24. print scount " files, " slines " lines, total size " ssize " bytes"
  25. system("del " ARGV[1])
  26. }
  27.