#!/usr/bin/perl -w use strict; my $data = 'Jul 30 19:39:06 server pure-ftpd: (user@68.158.32.189) [NOTICE] /home/shows//Genesis/Genesis 1978-06-24 FLAC/genesis1978-06-24-prefm-d1t04.flac downloaded (71074015 bytes, 60.83KB/sec) Jul 30 19:39:23 server pure-ftpd: (user@68.17.66.125) [NOTICE] /home/shows//Simon and Garfunkel/Simon and Garfunkel 2003-10-16/SG2003-10-16-d2t03.shn downloaded (2075533 bytes, 115.25KB/sec)'; my @result = $data =~ / ^(\w+)\s # month ($1) (\d+)\s # day ($2) ([\d:]+) # time ($3) .*?\((\w+) # user ($4) \@ # @ ([\d.]+?)\)(?:.|\n)*? # ip ($5) \[.+?\].*? # [NOTICE] until matching: (\/(?:.|\n)+?) # file ($6) until matching: (?:\s downloaded) # space and downloaded (?:.|\n)*? # optional dot or \n until matchin +g: \((\d+\s bytes) # size ($7) .+?([\d.]+KB\/sec)\) # speed ($8) /mxg; foreach (@result) { $_ =~ s/\n//; print $_, $/; print "\n" if $_ =~ /\/sec/; # separate entries } __END__ __OUTPUT__ Jul 30 19:39:06 user 68.158.32.189 /home/shows//Genesis/Genesis 1978-06-24 FLAC/genesis1978-06-24-prefm-d +1t04.flac 71074015 bytes 60.83KB/sec Jul 30 19:39:23 user 68.17.66.125 /home/shows//Simon and Garfunkel/Simon and Garfunkel 2003-10-16/SG2003 +-10-16-d2t03.shn 2075533 bytes 115.25KB/sec
In reply to Re: Pure Ftpd log regex
by Dietz
in thread Pure Ftpd log regex
by redhotpenguin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |