#! /usr/bin/gawk -f # Last edited on 2004-10-11 23:25:03 by stolfi BEGIN { # Counts characters, ignoring nothing. Newlines are counted too. split("", ct); } /^[ ]*([\#@]|$)/ { next; } /./ { lin = $0; # Count characters in {lin}: n = length(lin); for (i = 1; i <= n; i++) { c = substr(lin, i, 1); ct[c]++; } ct["NL"]++; next } END { for(c in ct) { if (c == " ") { xc = "SP"; } else if (c == "\n") { xc = "NL"; } else if (c == "\011") { xc = "HT"; } else { xc = c; } printf "%7d %s\n", ct[c], xc; } }