regex help needed

Mike Hernandez sequethin at gmail.com
Fri Oct 15 06:11:38 PDT 2004


On Fri, 15 Oct 2004 03:36:33 +0100 (BST), John Galbrit
<jgalbrit at yahoo.co.uk> wrote:
>  --- Bennett Todd <bet at rahul.net> wrote:
> >
> > grep '[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*' filename
> 
> Thanks! Though for anyone else interested, grep with the -o switch is
> needed if you just want to extract the IP's only.
> 
> Thanks again!

Just a side note here... If you want to actually do stuff with the ip
addresses after you get them from the log, you might want to look into
(g)awk. It's really great for stuff like that. I used it to create an
iptables script to block certain addresses that were trying to use my
webserver as a proxy. It's a really handy tool. If you're interested
let me know and I'll see if I can find that script ;)

Good luck

Mike



More information about the lfs-chat mailing list