Created
June 11, 2012 17:03
-
-
Save hanigamal/2911312 to your computer and use it in GitHub Desktop.
Parse S3 log files using Perl regular expressions
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/perl -w | |
use strict; | |
while (my $line=<>) { | |
my ($date, $host, $url_with_method, $status, $size, $referrer, $agent) = $line =~ | |
m/^\S+\s+\S+\s+\[(\S+\s+[\-|\+]\d{4})\]\s+(\S+)\s+\S+\s+\S+\s+\S+\s+\S+\s+"(\S+\s+\S+\s+[^"]+)"\s+(\d{3})\s+\S+\s+(\d+|-)\s+\d+\s+\d+\s+\d+\s+"(.*?)"\s+"(.*?)"/; | |
# Print relevant bits | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment