Last active
December 11, 2015 23:18
-
-
Save jasonhancock/4675588 to your computer and use it in GitHub Desktop.
stupid quick and dirty script to parse apache combined log format
This file contains 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 | |
use strict; | |
use warnings; | |
my $file = $ARGV[0] or die("No file passed"); | |
open IN, "<$file" or die("Can't open file $file"); | |
while(my $line=<IN>) { | |
if($line=~m/^(\S+|::1) \S+ \S+ \[([^\]]+)\] "([A-Z]+)[^"]*" \d+ (\d+|-) "[^"]*" "([^"]*)"$/m) { | |
my $user_ip = $1; | |
my $ts = $2; | |
my $method = $3; | |
my $bytes = $4; | |
my $ua = $5; | |
#print "$1 $2 $3 $4 $5\n"; | |
#print "it matched $line\n"; | |
} else { | |
print "line didn't match $line\n"; | |
} | |
} | |
close IN; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment