Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.04; 'python': 0.07; 'pm,': 0.11; 'wrote:': 0.14; 'awk': 0.16; 'grep': 0.16; 'subject:Convert': 0.16; 'subject:regex': 0.16; "that'll": 0.16; '16,': 0.16; 'command': 0.19; 'header:In-Reply-To:1': 0.22; 'mon,': 0.22; 'received:209.85.214.174': 0.23; 'received:mail- iw0-f174.google.com': 0.23; 'instead': 0.26; 'chris': 0.27; 'message-id:@mail.gmail.com': 0.28; 'sort': 0.30; 'to:addr:python- list': 0.32; 'done': 0.32; 'things': 0.33; 'print': 0.35; 'received:209.85': 0.37; 'received:google.com': 0.38; 'received:209.85.214': 0.39; 'likely': 0.39; 'to:addr:python.org': 0.39; 'could': 0.39; 'received:209': 0.39; 'header:Received:5': 0.40; '2011': 0.62; 'point:': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=2lQtwgM7b1zvvEo0MR56CHF5khsbZjcpT4EE0tb+oys=; b=rcIPlJI3tteY2EL3RkpSc5k7ofuY6InptlA0gRcq3Qk7LhdT+Vcbcllp6jiZMdpjad PORnhUA77M18akRRstx26OdgIV8XHWT9Ft0UE4eswk1nBHnETnMyY7Vmvmt9HvOFiHDS MMOV6oiNyEUVKNRFKTmH7RCTwOqnUIaEztJqs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=GVvVyraIwJQaIjONq9k/o991NrxBxoxk4Hl1rS3mr/WIR2Z8LnX+WR3JO8kKe0FVfE RG9sd9wVCo9kDKHIGFjbbLh/UyTjlyI4ed4Sntkch/uBGjna/F33EpiEXaHiHVx2Yx/9 tgPo6taHHqFQPi93sJ+HzqZISLl59TVEBN0OY= MIME-Version: 1.0 In-Reply-To: References: Date: Mon, 16 May 2011 18:31:03 +1000 Subject: Re: Convert AWK regex to Python From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 11 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305534667 news.xs4all.nl 41103 [::ffff:82.94.164.166]:41027 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5499 On Mon, May 16, 2011 at 6:19 PM, J wrote: > cat logs/pdu_log_fe.log | awk -F\- '{print $1,$NF}' | awk -F\. '{print $1= ,$NF}' | awk '{print $1,$4,$5}' | sort | uniq | while read service command = status; do echo "Service: $service, Command: $command, Status: $status, Occ= urrences: `grep $service logs/pdu_log_fe.log | grep $command | grep $status= | wc -l | awk '{ print $1 }'`" >> logs/pdu_log_fe_clean.log; done Small side point: Instead of "| sort | uniq |", you could use a Python dictionary. That'll likely speed things up somewhat! Chris Angelico