[ale] Question about awk

fletch at phydeaux.org fletch at phydeaux.org
Thu Sep 17 15:08:54 EDT 2009


> sed  's/.\+\[\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\].\+/\1/' < foo
> where foo has the pile of stuff you want the IP's from.

This (and the egrep version someone else had) match too much.  To be
pedantic and just match dotted IPs the regexp should be:

$ perl -MRegexp::Common=net -le 'print "".$RE{net}{IPv4}'
(?:(?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})[.](?:25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))


(And as to the original question, awk schmawk . . .

perl -lane '/Recipient address rejected.*\[([^]]+?)\]:/&&print $1'

but that goes without saying :)

-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org|  Vincent, you should cease askin'          \ o.O'
                      |  scary questions." -- Jules                =(___)=
                      |                                               U




More information about the Ale mailing list