tags:

views:

31

answers:

1

I'm doing something like zgrep "somepattern" access_log.X.gz But I find that a lot of the entries are from the same IP and I'd like to count them as one.

+1  A: 

I would use something like

zgrep "somepattern" access_log.X.gz | awk '{print $3}' | sort -u | wc -l

awk is to print out the field that contains the client IP address (I'm assuming it's the third field here, but adjust the number to match your log format), then sort -u sorts the IP addresses and removes duplicates, then wc -l counts the number of lines.

David Zaslavsky