From owner-freebsd-questions@FreeBSD.ORG Wed Aug 27 03:47:19 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 62FB71065676 for ; Wed, 27 Aug 2008 03:47:19 +0000 (UTC) (envelope-from bill@ayn.mi.celestial.com) Received: from ayn.mi.celestial.com (hayek.celestial.com [192.136.111.12]) by mx1.freebsd.org (Postfix) with ESMTP id 27DBE8FC0C for ; Wed, 27 Aug 2008 03:47:19 +0000 (UTC) (envelope-from bill@ayn.mi.celestial.com) Received: from localhost (localhost [127.0.0.1]) by ayn.mi.celestial.com (Postfix) with ESMTP id 70E9968CEA480; Tue, 26 Aug 2008 20:23:17 -0700 (PDT) X-Virus-Scanned: amavisd-new at mi.celestial.com Received: from ayn.mi.celestial.com ([127.0.0.1]) by localhost (ayn.mi.celestial.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id N4pT1H6Ef7IT; Tue, 26 Aug 2008 20:23:17 -0700 (PDT) Received: by ayn.mi.celestial.com (Postfix, from userid 203) id 548EC68610B24; Tue, 26 Aug 2008 20:23:17 -0700 (PDT) Date: Tue, 26 Aug 2008 20:23:17 -0700 From: Bill Campbell To: freebsd-questions@freebsd.org Message-ID: <20080827032317.GA29551@ayn.mi.celestial.com> Mail-Followup-To: freebsd-questions@freebsd.org References: <200808270312.m7R3CJNk076060@dc.cis.okstate.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200808270312.m7R3CJNk076060@dc.cis.okstate.edu> User-Agent: Mutt/1.5.18 OpenPKG/% (2008-05-17) Subject: Re: Regular Expression Trouble X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd@celestial.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Aug 2008 03:47:19 -0000 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.