Created
May 20, 2011 17:34
-
-
Save matthiasr/983380 to your computer and use it in GitHub Desktop.
Smiley statistics for IRC log files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/awk -f | |
| # usage: | |
| # ARGV[0] <user 1> <user 2> {-|<files>} | |
| BEGIN { | |
| print ARGC; | |
| if ( ARGC <= 3 ) { | |
| print "Usage:\n\t"ARGV[0]" <user 1> <user 2> <files>"; | |
| exit 1; | |
| } | |
| # intialization | |
| all=0;userall=0;smile=0;sad=0; | |
| # compose regular expressions | |
| all_re =".*<."ARGV[1]">"; | |
| userall_re = "[012][0-9]:[0-5][0-9] <."ARGV[1]">.*"ARGV[2]; | |
| smile_re ="[012][0-9]:[0-5][0-9] <."ARGV[1]">.*("ARGV[2]".*:-?\\)|:-?\\).*"ARGV[2]")"; | |
| sad_re ="[012][0-9]:[0-5][0-9] <."ARGV[1]">.*("ARGV[2]".*:-?\\(|:-?\\(.*"ARGV[2]")"; | |
| # prevent these from being interpreted as file names | |
| ARGV[1] = null; | |
| ARGV[2] = null; | |
| } | |
| $0 ~ all_re { all++;} | |
| $0 ~ userall_re { userall++;} | |
| $0 ~ smile_re { smile++;} | |
| $0 ~ sad_re { sad++;} | |
| END { print smile/userall, sad/userall, userall/all, smile/all, all, userall, smile, sad; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment