Here is a small one liner which will pull a list of IP addresses from a file, sort them, select only unique ip’s and then list them from greatest to least.

perl -ne 'while (/([0-9]+\.){3}[0-9]+/g) {print "$&\n"};' /var/log/exim_mainlog |uniq -c |sort -nr |head -100

You can also modify this to include an output file by adding

> file.txt

to the end of the string.

Was this post helpful?