#!/usr/bin/awk -f # vim: ts=4 sw=4 et ft=awk # # Given input containing only lines of the form # # category count # # this script computes and prints the total count for each category. { if (NF == 2) { cnt[$1] += $2; } else { printf("unexpected line: <%s>\n", $0); } } END { for (i in cnt) { printf("%-30s %12d\n", i, cnt[i]); } }