gno/usr.bin/awk/tests/wc.awk
tribby ddb82cb2e0 Remaining files for awk 2.0 that were left out of the previous checkin.
Maybe someday I'll become adept at using cvs...
1998-04-07 17:06:53 +00:00

27 lines
595 B
Awk

# awk program to emulate the wc command
{
# Has input file changed?
if (FILENAME != file) {
if (startup == 0) {
# This is just the first time through
startup = 1;
}
else {
printf " %7d %7d %7d %s\n", nl, nw, nc, file;
tnl += nl; tnw += nw; tnc += nc;
nl = 0; nw = 0; nc = 0;
}
file = FILENAME;
numfiles++
}
nl++; nw += NF; nc += length($0)+1;
}
END {
printf " %7d %7d %7d %s\n", nl, nw, nc, file;
if (numfiles > 1) {
tnl += nl; tnw += nw; tnc += nc;
printf " %7d %7d %7d total\n", tnl, tnw, tnc;
}
}