File: srcstat2.awk

package info (click to toggle)
mawk 1.3.3-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,204 kB
  • ctags: 1,530
  • sloc: ansic: 13,023; yacc: 994; awk: 629; sh: 330; makefile: 164
file content (28 lines) | stat: -rw-r--r-- 753 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Ben Myers <0003571400@mcimail.com>

# Sum up number, line count, and sizes of SOURCE files in current directory
# run with 
#       bmawk -fsrcsize.awk workfile
# or similar command syntax with your awk program
# where workfile is a work file
BEGIN {
# redirection done by shelled command
system("dir *.* >workfile")
ssize = 0   # size accumulator
slines = 0  # line counter
scount = 0  # obj counter
exit
}
END {
# Now read workfile back in
    while (getline < "workfile" > 0) {
    if ($2 == "C" || $2 == "H" || $2 == "CPP" || $2 == "HPP")  {
	filename = sprintf("%s.%s", $1, $2)
	ssize += $3
	while (getline < filename > 0) {slines++}
	scount++
	}
    }
print scount " files, " slines " lines, total size " ssize " bytes"
system("del workfile")
}