Regular Expression Trouble

Bill Campbell freebsd at
Wed Aug 27 03:47:19 UTC 2008

On Tue, Aug 26, 2008, Martin McCormick wrote:
>I am trying to isolate only the MAC addresses that appear in
>dhcpd logs.
>For anyone who is interested, the sed construct that should do
>this looks like:
> sed 's/.*\([[ your regular expression ]]\).*/\1/' 
>The \1 tells sed to only print what matched and skip all the rest.

I just tried this, and it worked:

sed -n 's;.* to \([0-9:a-z]*\) via.*;\1;p' logfile

It would have been easier in perl or python where one could use
the pattern '.* to (\S+) via.*'.

INTERNET:   bill at  Bill Campbell; Celestial Software LLC
URL:  PO Box 820; 6641 E. Mercer Way
Voice:          (206) 236-1676  Mercer Island, WA 98040-0820
Fax:            (206) 232-9186

My reading of history convinces me that most bad government results
from too much government. --Thomas Jefferson.

More information about the freebsd-questions mailing list