awk ' BEGIN { ORS = "" } NR == 1 { nfields = NF } { if ($0 ~ /[^0-9. \t]/) { print "\nRecord " NR " skipped:\n\t" print $0 "\n" next } else { for (count = 1; count <= nfields; count++) { printf "%10.2f", $count > "tally.out" sum[count] += $count gtotal += $count } print "\n" > "tally.out" } } END { for (count = 1; count <= nfields; count++) { print " -------" > "tally.out" } print "\n" > "tally.out" for (count = 1; count <= nfields; count++) { printf "%10.2f", sum[count] > "tally.out" } print "\n\n Grand Total " gtotal "\n" > "tally.out" } ' < numbers