From owner-freebsd-questions@FreeBSD.ORG Thu Aug 28 08:51:23 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 AAE60106566B for ; Thu, 28 Aug 2008 08:51:23 +0000 (UTC) (envelope-from peter@boosten.org) Received: from smtpq2.groni1.gr.home.nl (smtpq2.groni1.gr.home.nl [213.51.130.201]) by mx1.freebsd.org (Postfix) with ESMTP id 7028E8FC1D for ; Thu, 28 Aug 2008 08:51:23 +0000 (UTC) (envelope-from peter@boosten.org) Received: from [213.51.130.190] (port=44973 helo=smtp1.groni1.gr.home.nl) by smtpq2.groni1.gr.home.nl with esmtp (Exim 4.60) (envelope-from ) id 1KYdDs-0006dr-RP; Thu, 28 Aug 2008 10:51:20 +0200 Received: from cp268254-a.landg1.lb.home.nl ([84.25.65.88]:20503 helo=ra.egypt.nl) by smtp1.groni1.gr.home.nl with esmtp (Exim 4.60) (envelope-from ) id 1KYdDs-0008F2-5O; Thu, 28 Aug 2008 10:51:20 +0200 Received: from [127.0.0.1] (xp.egypt.nl [192.168.13.35]) by ra.egypt.nl (Postfix) with ESMTP id EC19439841; Thu, 28 Aug 2008 10:51:18 +0200 (CEST) Message-ID: <48B66706.9060303@boosten.org> Date: Thu, 28 Aug 2008 10:51:18 +0200 From: Peter Boosten User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <200808271325.m7RDP28b044255@dc.cis.okstate.edu> <20080827152900.GB30783@it.ca> In-Reply-To: <20080827152900.GB30783@it.ca> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: 0.1 (/) Cc: Martin McCormick 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: Thu, 28 Aug 2008 08:51:23 -0000 Paul Chvostek wrote: >> This is an attempt to isolate every MAC address that >> appears and then sort and count them to see who is having >> trouble or, in some cases, is causing trouble. > > Then you still may want to use awk for some of that... > > cat /var/log/dhcpd.log | \ > sed -nE 's/.*([0-9a-f]{2}(:[0-9a-f]{2}){5}).*/\1/p' | \ > awk ' > { a[$1]++; } > END { > for(i in a){ > printf("%7.0f\t%s\n", a[i], i); > } > } > ' | sort -nr > Euhmm: sed -nE 's/.*([0-9a-f]{2}(:[0-9a-f]{2}){5}).*/\1/p' /var/log/dhcpd.log|\ sort | uniq -c :-) Peter -- http://www.boosten.org