• Home
  • Shell
    • Emacs
    • Perl
    • screen
    • sed
  • Ubuntu
    • VNC
  • Web Development
    • Javascript
    • Joomla
    • MySQL
    • osTicket
  • Windows
    • Gimp

Posts tagged IP

Perl> Get IP only from logfiles

Oct26
2010
Written by Scott Rowley

Being an ISP admin, I have regular need to find IP addresses listed in large logfiles. The following will grab anything that appears to be an IP and list it out for you, from there you can sort or whatever you want to do with the list.

perl -ne 'print "$&n" while m#d+.d+.d+.d+#g' <logfile>

Or just throw it in a bash script for easier remembering:

getip.sh

#!/bin/bash
perl -ne 'print "$&\n" while m#\d+\.\d+\.\d+\.\d+#g' $1;
Posted in Perl - Tagged BASH, log, logfile, Perl, print

Corrections? Questions? Comments?

Find an error?
Everything work out great for you?
Have some feedback?
Like to see something added to the article?

PLEASE leave us a comment after the article and let us know how we are doing, or if something needs corrected, improved or clarified.

Thank you!
- The Management

Advertisement

Sudo Bash
By Geeks - For Geeks

Back to Top