bozo me. The self-reply was after I had merged the broken one-liner with the next broken one-liner and fixed both. <br><br>Yes, the $i was a fubar. But my run gave really strange results:<br>5778<br>0<br>4753<br>105<br>378<br>
0<br>3486<br>0<br>5460<br>0<br>5253<br>0<br>3570<br>105<br>0<br>1<br>which looks like FS = NULL<br><br>print NF is correct as it does the "RightThing". William was right. <br><br><div class="gmail_quote">On Wed, Apr 21, 2010 at 3:53 PM, Geoffrey <span dir="ltr"><<a href="mailto:lists@serioustechnology.com">lists@serioustechnology.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">Jim Kinney wrote:<br>
> I was testing an awk one-liner and hit one that doesn't work.<br>
><br>
> awk '{ s = 0; for (i = 1; i <= NF; i++) s = s+$i; print s }'<br>
<br>
</div>I think you want:<br>
<div><div></div><div class="h5"><br>
awk '{ s = 0; for (i = 1; i <= NF; i++) s = s+i; print s }'<br>
<br>
><br>
> should return the number of word/field per line. I haven't tinkered<br>
> with the FS setting. the file I'm testing on is an ipsolorum I<br>
> generated days ago. It's at the bottom of this email.<br>
><br>
><br>
> When I test the values I should get with: grep -o " " test| grep -c "<br>
> " where test has the ipsolorum text I get 626 which, without actually<br>
> counting seems OK if not a bit high.<br>
><br>
> But the awk returns:<br>
><br>
> 0 0 0 0 0 0 0 0 0 0 0 0 12 0 0 0<br>
><br>
><br>
> Correct # of lines but totally crap number of words.<br>
><br>
><br>
><br>
><br>
><br>
><br>
> -- -- James P. Kinney III Actively in pursuit of Life, Liberty and<br>
> Happiness<br>
><br>
><br>
</div></div>> ------------------------------------------------------------------------<br>
><br>
><br>
> _______________________________________________ Ale mailing list<br>
<div class="im">> <a href="mailto:Ale@ale.org">Ale@ale.org</a> <a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a> See JOBS,<br>
> ANNOUNCE and SCHOOLS lists at <a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br>
<br>
</div><font color="#888888">--<br>
Until later, Geoffrey<br>
<br>
"I predict future happiness for America if they can prevent<br>
the government from wasting the labors of the people under<br>
the pretense of taking care of them."<br>
- Thomas Jefferson<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>-- <br>James P. Kinney III<br>Actively in pursuit of Life, Liberty and Happiness <br><br>