From owner-freebsd-questions@FreeBSD.ORG Sat Aug 23 00:18:15 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 630EE1065700 for ; Sat, 23 Aug 2008 00:18:15 +0000 (UTC) (envelope-from walt@wump.org) Received: from mta31.charter.net (mta31.charter.net [216.33.127.82]) by mx1.freebsd.org (Postfix) with ESMTP id ED1488FC17 for ; Sat, 23 Aug 2008 00:18:14 +0000 (UTC) (envelope-from walt@wump.org) Received: from aarprv06.charter.net ([10.20.200.76]) by mta31.charter.net (InterMail vM.7.08.03.00 201-2186-126-20070710) with ESMTP id <20080823001807.WRYC8683.mta31.charter.net@aarprv06.charter.net>; Fri, 22 Aug 2008 20:18:07 -0400 Received: from [10.0.0.10] (really [68.116.98.9]) by aarprv06.charter.net with ESMTP id <20080823001806.LWWU29012.aarprv06.charter.net@[10.0.0.10]>; Fri, 22 Aug 2008 20:18:06 -0400 Mime-Version: 1.0 Message-Id: In-Reply-To: <200808220759.m7M7xuh0047625@lurza.secnetix.de> References: <200808220759.m7M7xuh0047625@lurza.secnetix.de> Date: Fri, 22 Aug 2008 17:18:01 -0700 To: freebsd-questions@FreeBSD.ORG, Oliver Fromme From: Walt Pawley Content-Type: text/plain; charset="us-ascii" X-Chzlrs: 0 Cc: Subject: Re: sed/awk, instead of Perl 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: Sat, 23 Aug 2008 00:18:15 -0000 At 9:59 AM +0200 8/22/08, Oliver Fromme wrote: > - The perl command you wrote above is pretty much a sed > command anyway (except you incorrectly used non-portable > regular expression syntax). Why use perl to execute a > sed command? At the risk of beating this to death, I just happened to stumble on a real world example of why one might want to use Perl for sed-ly stuff. I wanted to pull off the accessor's address from each line of an Apache access log file. So, I figured after this discussion that sed was the way to go. Then I got curious and did the following: wump$ ls -l Desktop/klog -rw-r--r-- 1 wump 1001 52753322 22 Aug 16:37 Desktop/klog wump$ time sed "s/ .*//" Desktop/klog > kadr1 real 0m10.800s user 0m10.580s sys 0m0.250s wump$ time perl -pe 's/ .*//' Desktop/klog > kadr2 real 0m0.975s user 0m0.700s sys 0m0.270s wump$ cmp kadr1 kadr2 wump$ Why disparity in execution speed? Beats me, but my G5's fans started to take off running the sed command. I don't think the Perl command took long enough to register thermally. Curious. FWIW: I did this with an older version of Mac OS X, rather FreeBSD so it could easily not show the same results if I moved the log file to a FreeBSD box and did it there. -- Walter M. Pawley Wump Research & Company 676 River Bend Road, Roseburg, OR 97470 541-672-8975