Skip to content

Instantly share code, notes, and snippets.

@EdGuiness
Created January 8, 2015 10:07
Show Gist options
  • Select an option

  • Save EdGuiness/c815f99d2bcb42714165 to your computer and use it in GitHub Desktop.

Select an option

Save EdGuiness/c815f99d2bcb42714165 to your computer and use it in GitHub Desktop.
Dump IP addresses with count from IIS log file
use strict;use warnings;
my %ipaddrs;
while (<DATA>) {
while (/\b(\d+\.\d+\.\d+\.\d+)\b/g) {
$ipaddrs{$&}++;
}
}
foreach my $ip (keys %ipaddrs) {
print "$ip\t$ipaddrs{$ip}\n";
}
__DATA__
@EdGuiness
Copy link
Author

Also... ...utils\sort --key=2 -n -r to sort output descending numeric order

@EdGuiness
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment