From owner-freebsd-questions@FreeBSD.ORG Wed Aug 27 03:26:31 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 EFF09106567A for ; Wed, 27 Aug 2008 03:26:31 +0000 (UTC) (envelope-from pprocacci@datapipe.com) Received: from fmailhost05.isp.att.net (fmailhost05.isp.att.net [204.127.217.105]) by mx1.freebsd.org (Postfix) with ESMTP id C174F8FC19 for ; Wed, 27 Aug 2008 03:26:31 +0000 (UTC) (envelope-from pprocacci@datapipe.com) Received: from [10.5.21.122] (adsl-241-169-57.bna.bellsouth.net[74.241.169.57]) by isp.att.net (frfwmhc05) with ESMTP id <20080827032631H0500e6e7ae>; Wed, 27 Aug 2008 03:26:31 +0000 X-Originating-IP: [74.241.169.57] Message-ID: <48B4C966.9000602@datapipe.com> Date: Tue, 26 Aug 2008 22:26:30 -0500 From: "Paul A. Procacci" User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Martin McCormick References: <200808270312.m7R3CJNk076060@dc.cis.okstate.edu> In-Reply-To: <200808270312.m7R3CJNk076060@dc.cis.okstate.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: Regular Expression Trouble X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Aug 2008 03:26:32 -0000 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 am doing something wrong with the regular expression > that is supposed to recognise a MAC address. MAC addresses look > like 5 pairs of hex digits followed by :'s and then a 6TH pair > to end the string. > > I have tried: > > [[:xdigit:][:xdigit:][:punct:] > > Sorry. It won't all fit on a line, but there should be a string > of 5 pairs and the : and then the 6TH pair followed by the > closing ] so the expression ends with ]] > > One should also be able to put: > > [[:xdigit:][:xdigit:][:punct:]]\{5,5\}[[:xdigit:][:xdigit]] > > Any ideas as to what else I can try? > > What happens is I get single characters per line that look like > the first or maybe the last character in that line, but > certainly nothing useful or nothing that remotely looks like a > MAC address. > > Any ideas as to what's wrong with the regular > expression? > > Many thanks. > > Martin McCormick WB5AGZ Stillwater, OK > Systems Engineer > OSU Information Technology Department Telecommunications Services Group > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" > I don't have a seperate dhcp log and you didn't make it clear if you do, but I do have something similar written for awk that parses the system log file. awk ' /DHCPREQUEST/ { print $10 } ' /var/log/messages Maybe that will help. ~Paul