# =================================================================== # AWK PROGRAM TO TAB INPUT DELIMITED BY ":" AND TOTAL NUMERIC COLUMNS # =================================================================== # define an array, numcol, which determines whether # a field is numeric or string # NB all lines are assumed to have the same structure as the first line NR==1 {nfld=NF for (i=1; i<=NF; i++) numcol[i]=isnum($i) } # if a column is numeric then add the value to the total for the column {for(i=1; i<=NF; i++) {if (numcol[i]) sum[i]+=$i printf("%s\t",$i) } printf("\n") } END {for (i=1; i<=nfld ;i++) {if (numcol[i]) printf("%g", sum[i]) else printf("--") printf(i