replying to myself as I figured out that the one-liner was just plain broken.<br><br>cat test | awk &#39;{  s = s + NF }; END { print s }&#39;<br><br>works as desired. And matched output from wc -w<br><br><div class="gmail_quote">
On Wed, Apr 21, 2010 at 3:06 PM, Jim Kinney <span dir="ltr">&lt;<a href="mailto:jim.kinney@gmail.com">jim.kinney@gmail.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;">
I was testing an awk one-liner and hit one that doesn&#39;t work. <br><pre>awk &#39;{ s = 0; for (i = 1; i &lt;= NF; i++) s = s+$i; print s }&#39;<br><br>should return the number of word/field per line. I haven&#39;t tinkered with the FS setting. the file I&#39;m testing on is an ipsolorum I generated days ago. It&#39;s at the bottom of this email.<br>

<br>When I test the values I should get with:<br>grep -o &quot; &quot; test| grep -c &quot; &quot;<br>where test has the ipsolorum text I get 626 which, without actually counting seems OK if not a bit high.<br><br>But the awk returns:<br>

0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>12<br>0<br>0<br>0<br><br><br>Correct # of lines but totally crap number of words.<br><br><br><br><br></pre><br clear="all"><br>-- <br><font color="#888888">-- <br>
James P. Kinney III<br>
Actively in pursuit of Life, Liberty and Happiness         <br><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>-- <br>James P. Kinney III<br>Actively in pursuit of Life, Liberty and Happiness         <br><br>