$ cat access_log | perl -pe 'if (s/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).*"(GET|POST|HEAD) (.*?) HTTP\/.*$/$1,$3/) { print } else { print STDERR }' 2>out.err > out.csv
####
[...]
72.30.161.243,/
72.30.161.243,/
125.224.206.168 - - [04/Oct/2009:00:13:42 +0200] "-" 408 - "-" "-"
125.224.206.168 - - [04/Oct/2009:00:13:42 +0200] "-" 408 -
125.224.206.168 - - [04/Oct/2009:00:13:47 +0200] "CONNECT 203.188.201.253:25 HTTP/1.1" 404 516 "-" "-"
125.224.206.168 - - [04/Oct/2009:00:13:47 +0200] "CONNECT 203.188.201.253:25 HTTP/1.1" 404 516
96.243.255.188,//phpMyAdmin/
[...]
####
72.30.161.243 - - [03/Oct/2009:17:21:43 +0200] "GET / HTTP/1.0" 404 516 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp/3.0; http://help.yahoo.co
m/help/us/ysearch/slurp)"
72.30.161.243 - - [03/Oct/2009:17:21:43 +0200] "GET / HTTP/1.0" 404 516
125.224.206.168 - - [04/Oct/2009:00:13:42 +0200] "-" 408 - "-" "-"
125.224.206.168 - - [04/Oct/2009:00:13:42 +0200] "-" 408 -
125.224.206.168 - - [04/Oct/2009:00:13:47 +0200] "CONNECT 203.188.201.253:25 HTTP/1.1" 404 516 "-" "-"
125.224.206.168 - - [04/Oct/2009:00:13:47 +0200] "CONNECT 203.188.201.253:25 HTTP/1.1" 404 516
96.243.255.188 - - [04/Oct/2009:00:26:17 +0200] "GET //phpMyAdmin/ HTTP/1.1" 404 516 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
96.243.255.188 - - [04/Oct/2009:00:26:17 +0200] "GET //phpMyAdmin/ HTTP/1.1" 404 516