#! /usr/bin/gawk -f # Last edited on 2000-05-26 06:55:02 by stolfi # Totalizes fields of input BEGIN { maxnf = 0; split("", tot); } /^[#]/ { next; } /./{ for (i=1; i<=NF; i++) { f = $(i); if (f ~ /^[-+]?[0-9]+[.]?[0-9]*$/) { tot[i] += f; if (i > maxnf) { maxnf = i; } } } } END { sep = ""; for (i=1; i<=maxnf; i++) { printf "%s%d", sep, tot[i]; sep = " "; } printf "\n"; }