in reply to Sorting log files with IP addresses (duplicates)
if you have the file content in an array, you could try something like:
my @sorted = map { $_->[4] } sort { $a->[0] <=> $b->[0] or $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] or $a->[3] <=> $b->[3] } map { if( my (@ipParts) = $_ =~ m/dst outside:(\d+)\.(\d+)\.(\d+)\.(\d+)/ ) { [ @ipParts, $_ ] } else { # what shell I do if pattern not found? use 0.0.0.0? [ 0, 0, 0, 0, $_ ]; } # else } @input;
Perhaps you have to change the pattern match...
See also: Schwartzian Transform
Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting log files with IP addresses (duplicates)
by salva (Canon) on Apr 21, 2006 at 09:37 UTC |