Forum Moderators: bakedjake

Message Too Old, No Replies

counting hits and unique visitors using grep?

         

bb22

2:46 pm on Mar 1, 2004 (gmt 0)

10+ Year Member



What command would i use to parse a server log to get all hits received on a specific date and the number of uniques the same day?

Thanks

hyperbole

12:33 am on Mar 3, 2004 (gmt 0)

10+ Year Member



Doesn't that kinda depend on how your logs are organized? And which operating system you using?

DaScribbler

2:34 pm on Mar 3, 2004 (gmt 0)

10+ Year Member



grep by date
sort it to get each reoccurance adjacent in the list
uniq the list
then wc to count them (use the -l option so only lines are counted)
if the log contains anything other than hits, pass it through another grep containing a string denoting a hit from an incoming server.

grep '<date>' <logfile> ¦ sort ¦ uniq ¦ wc -l

to get All hits for the day, just grep and wc

DaScribbler

10:33 pm on Mar 3, 2004 (gmt 0)

10+ Year Member



whups...almost forgot, make sure the sort is on a field that will place similar hits together (ie...whichever field the servernames are on, or IP's etc) otherwise the sort will be based on time and date, resulting in the uniq command not noticing the duplicate entries.