#! /usr/bin/gawk -f # Last edited on 2004-02-28 02:39:26 by stolfi BEGIN { # Counts blank-delimited words. # Ignores #-comments and {}-comments. split("", ct); } /^[ ]*([\#@]|$)/ { next; } /./ { lin = $0; # Replace inlined @{}{}-constructs by their text content: lin = gensub(/[@][{][^{}]*[}][{]([^{}]*)[}]/, "\\1", "g", lin); lin = gensub(/[@][a-z]*[{]([^{}]*)[}]/, "\\1", "g", lin); # Remove {}-comments: gsub(/[{][^{}]*[}]/, "", lin); $0 = lin; for (i = 1; i <= NF; i++) { c = $(i); ct[c]++; } next } END { for(c in ct) { printf "%7d %s\n", ct[c], c; } }