| 1 |
# Ben Myers <[email protected]> |
| 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 |
ssize = 0 # size accumulator |
| 12 |
slines = 0 # line counter |
| 13 |
scount = 0 # obj counter |
| 14 |
exit |
| 15 |
} |
| 16 |
END { |
| 17 |
# Now read workfile back in |
| 18 |
while (getline < "workfile" > 0) { |
| 19 |
if ($2 == "C" || $2 == "H" || $2 == "CPP" || $2 == "HPP") { |
| 20 |
filename = sprintf("%s.%s", $1, $2) |
| 21 |
ssize += $3 |
| 22 |
while (getline < filename > 0) {slines++} |
| 23 |
scount++ |
| 24 |
} |
| 25 |
} |
| 26 |
print scount " files, " slines " lines, total size " ssize " bytes" |
| 27 |
system("del workfile") |
| 28 |
} |