<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#e0e0e0">
Jim,<br>
<br>
Have you tried the following?<br>
<br>
awk '{print NF}' test<br>
<br>
That yielded the following for me:<br>
<br>
107<br>
0<br>
97<br>
14<br>
27<br>
0<br>
83<br>
0<br>
104<br>
0<br>
102<br>
0<br>
84<br>
14<br>
0<br>
1<br>
<br>
<br>
<br>
Wiliam<br>
<br>
<br>
On 04/21/2010 03:06 PM, Jim Kinney wrote:
<blockquote
cite="mid:y2k437d2f231004211206s47199c8dnf12def4f829a9b88@mail.gmail.com"
type="cite">I was testing an awk one-liner and hit one that doesn't
work. <br>
<pre>awk '{ s = 0; for (i = 1; i <= NF; i++) s = s+$i; print s }'
should return the number of word/field per line. I haven't tinkered with the FS setting. the file I'm testing on is an ipsolorum I generated days ago. It's at the bottom of this email.
When I test the values I should get with:
grep -o " " test| grep -c " "
where test has the ipsolorum text I get 626 which, without actually counting seems OK if not a bit high.
But the awk returns:
0
0
0
0
0
0
0
0
0
0
0
0
12
0
0
0
Correct # of lines but totally crap number of words.
</pre>
<br clear="all">
<br>
-- <br>
-- <br>
James P. Kinney III<br>
Actively in pursuit of Life, Liberty and Happiness <br>
<br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Ale mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Ale@ale.org">Ale@ale.org</a>
<a class="moz-txt-link-freetext" href="http://mail.ale.org/mailman/listinfo/ale">http://mail.ale.org/mailman/listinfo/ale</a>
See JOBS, ANNOUNCE and SCHOOLS lists at
<a class="moz-txt-link-freetext" href="http://mail.ale.org/mailman/listinfo">http://mail.ale.org/mailman/listinfo</a>
</pre>
</blockquote>
<br>
</body>
</html>