[Tutor] Simple Stats on Apache Logs

Lao Mao laomao1975 at googlemail.com
Thu Feb 11 11:50:41 CET 2010

Hi Christian,

grep -c <keyword> <file-mask eg. *.log>
> or if you are looking for only stuff for today for eg then
> grep <date> | grep -c <keyword> <file-mask>

I don't see how that will produce figures per hour!

That would be the simplest implementation.  For a python implementation
> think about dictionaries with multiple layers like {Date: {Keyword1: Count,
> Keyword2: Count}.  Essentially you would just iterate over the file, check
> if the line contains your keyword(s) that you are looking for and then
> incrementing the counter for it.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100211/d46697e4/attachment-0001.htm>

More information about the Tutor mailing list