Posted By

benjay on 09/30/09


Tagged

sort Bash ruby grep wc cat


Versions (?)

Count unique users from a log file for a given time period


 / Published in: Bash
 

Sample log line:

[INFO] 2009-03-06 20:47:35 | controller::bla | user: vincentvega | ip: 127.0.0.1

  1. cat xyz.log | grep "2009-03" | ruby -ne 'puts $1 if $_ =~ /user:\s(\w+)/' | sort -u | wc -l

Report this snippet  

You need to login to post a comment.