<HTML><FONT FACE=arial,helvetica><FONT COLOR="#000000" FACE="Geneva" FAMILY="SANSSERIF" SIZE="2" STYLE="BACKGROUND-COLOR: #FFFFFF">For mine... if you are not concerned so much about the exact number then change:<BR>
<BR>
"read from file the_file for numLines lines"<BR>
to<BR>
"read from file the_file for numLines"<BR>
<BR>
for a big speedup.<BR>
<BR>
and<BR>
<BR>
up the chunkSize to something closer to your available memory, for example (8*1024*1024) = 8MB.<BR>
<BR>
As for innacurate results, it looks like they are roughly double in my case.<BR>
Any chance "mystic_mouse" appears more than once on a line?<BR>
<BR>
That would probably cause it- didn't think of that without seeing the file =).<BR>
<BR>
Of, of course, I could have made an error somewhere (nah!).<BR>
<BR>
Here's a modified script, which attempts to fix the supposed multiple matches per line:<BR>
Try calling it with parameters such as 2,4,8,16,32, etc (these are now in MB)::<BR>
<BR>
<BR>
#!/usr/local/bin/mc<BR>
on startup<BR>
## initialize variables: try adjusting numLines<BR>
put "/gig/tmp/log/access_log" into the_file<BR>
put ($1*1024) into chunkSize ## parameter is now number of MB<BR>
put 0 into counter<BR>
<BR>
open file the_file<BR>
<BR>
repeat until (isEOF = TRUE)<BR>
## read the specified number of lines, check if we are at the end of the file<BR>
read from file the_file for chunkSize<BR>
put (it&cr) into thisChunk<BR>
put (the result = "eof") into isEOF<BR>
<BR>
## count the number of matches in this chunk<BR>
put offset("mystic_mouse", thisChunk) into theOffset<BR>
repeat until (theOffset = 0)<BR>
add 1 to counter<BR>
put offset("mystic_mouse", thisChunk, theOffset) into tempOffset<BR>
if (tempOffset > 0) then <BR>
add tempOffset to theOffset<BR>
add offset(return, thisChunk, theOffset) to theOffset<BR>
else put 0 into theOffset<BR>
end repeat<BR>
<BR>
end repeat<BR>
<BR>
close file the_file<BR>
<BR>
put counter<BR>
end startup<BR>
<BR>
HTH.<BR>
Brian<BR>
<BR>
<BR>
</FONT><FONT COLOR="#000000" FACE="Geneva" FAMILY="SANSSERIF" SIZE="2" STYLE="BACKGROUND-COLOR: #FFFFFF"></FONT></HTML>