#! /bin/csh -f
# Last edited on 2002-01-05 14:05:48 by stolfi

set usage = "$0 < INFILE > COUNTS.cts"

if ( $#argv != 0 ) then
  echo "usage: ${usage}"; exit 1
endif

gawk \
  '/./{ \
    $0 = gensub(/(.)/, "\\1\n", "g", $0); \
    gsub(/[ ]/, "\! SP"); \
    gsub(/$/, "\! NL"); \
    print; \
  }' \
  | sort | uniq -c | expand \
  | sort -b +0 -1nr +1 -3 \
  | sed -e 's/\! //g' 
