Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Processing in Awk

Status
Not open for further replies.

AwkRookie

Programmer
Oct 15, 2002
10
US
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(&quot;%g&quot;,sum)
if (i<maxfld)
printf(&quot;\t&quot;)
else
printf(&quot;\n&quot;)
}
}

According to the Aho, Kernighan, Weinberger text p. 68, &quot;the program prints nothing if the input file is empty&quot;. 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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top