I am using all-numeric data, tab-delimited, as input to the following code:
{for (i=1; i<=NF; i++)
sum+=$i
if(NF>maxfld)
maxfld=NF
}
END {for (i=1; i<=maxfld; i++) {
printf("%g",sum)
if (i<maxfld)
printf("\t"
else
printf("\n"
}
}
According to the Aho, Kernighan, Weinberger text p. 68, "the program prints nothing if the input file is empty". I get no run-time or syntax errors and indeed am getting no output.
What could be wrong with my input (double-precision 8-column) or what is obviously missing from the above code in order to get it to run? And please, be patiet, I am an Awk newbie!
{for (i=1; i<=NF; i++)
sum+=$i
if(NF>maxfld)
maxfld=NF
}
END {for (i=1; i<=maxfld; i++) {
printf("%g",sum)
if (i<maxfld)
printf("\t"
else
printf("\n"
}
}
According to the Aho, Kernighan, Weinberger text p. 68, "the program prints nothing if the input file is empty". I get no run-time or syntax errors and indeed am getting no output.
What could be wrong with my input (double-precision 8-column) or what is obviously missing from the above code in order to get it to run? And please, be patiet, I am an Awk newbie!