Date: Fri, 22 Aug 2008 17:18:01 -0700 From: Walt Pawley <walt@wump.org> To: freebsd-questions@FreeBSD.ORG, Oliver Fromme <olli@lurza.secnetix.de> Subject: Re: sed/awk, instead of Perl Message-ID: <p0624080cc4d504c10465@[10.0.0.10]> In-Reply-To: <200808220759.m7M7xuh0047625@lurza.secnetix.de> References: <200808220759.m7M7xuh0047625@lurza.secnetix.de>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <walt@wump.org> Wump Research & Company 676 River Bend Road, Roseburg, OR 97470 541-672-8975
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p0624080cc4d504c10465>