Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Aug 2008 20:23:17 -0700
From:      Bill Campbell <freebsd@celestial.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Regular Expression Trouble
Message-ID:  <20080827032317.GA29551@ayn.mi.celestial.com>
In-Reply-To: <200808270312.m7R3CJNk076060@dc.cis.okstate.edu>
References:  <200808270312.m7R3CJNk076060@dc.cis.okstate.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
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.*'.

Bill
-- 
INTERNET:   bill@celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080827032317.GA29551>