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 &quot;RightThing&quot;. William was right. <br><br><div class="gmail_quote">On Wed, Apr 21, 2010 at 3:53 PM, Geoffrey <span dir="ltr">&lt;<a href="mailto:lists@serioustechnology.com">lists@serioustechnology.com</a>&gt;</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>
&gt; I was testing an awk one-liner and hit one that doesn&#39;t work.<br>
&gt;<br>
&gt; awk &#39;{ s = 0; for (i = 1; i &lt;= NF; i++) s = s+$i; print s }&#39;<br>
<br>
</div>I think you want:<br>
<div><div></div><div class="h5"><br>
awk &#39;{ s = 0; for (i = 1; i &lt;= NF; i++) s = s+i; print s }&#39;<br>
<br>
&gt;<br>
&gt; should return the number of word/field per line. I haven&#39;t tinkered<br>
&gt; with the FS setting. the file I&#39;m testing on is an ipsolorum I<br>
&gt; generated days ago. It&#39;s at the bottom of this email.<br>
&gt;<br>
&gt;<br>
&gt; When I test the values I should get with: grep -o &quot; &quot; test| grep -c &quot;<br>
&gt; &quot; where test has the ipsolorum text I get 626 which, without actually<br>
&gt; counting seems OK if not a bit high.<br>
&gt;<br>
&gt; But the awk returns:<br>
&gt;<br>
&gt; 0 0 0 0 0 0 0 0 0 0 0 0 12 0 0 0<br>
&gt;<br>
&gt;<br>
&gt; Correct # of lines but totally crap number of words.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; -- -- James P. Kinney III Actively in pursuit of Life, Liberty and<br>
&gt; Happiness<br>
&gt;<br>
&gt;<br>
</div></div>&gt; ------------------------------------------------------------------------<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________ Ale mailing list<br>
<div class="im">&gt; <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>
&gt; 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>
&quot;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.&quot;<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>