Date: Tue, 26 Aug 2008 14:39:03 +0200 (CEST) From: Oliver Fromme <olli@lurza.secnetix.de> To: freebsd-questions@FreeBSD.ORG, walt@wump.org Subject: Re: sed/awk, instead of Perl Message-ID: <200808261239.m7QCd3cp029363@lurza.secnetix.de> In-Reply-To: <p0624080cc4d504c10465@[10.0.0.10]>
next in thread | previous in thread | raw e-mail | index | archive | help
Walt Pawley wrote: > wump$ time sed "s/ .*//" Desktop/klog > kadr1 Note that this is a job for cut(1): $ cut -d" " -f1 input Interestingly, the fastest way to do that job is to use a regular expression with Python. This is about twice as fast as the proposed perl solution: $ python -c 'import re; print re.sub(" .*\n", "\n", file("input").read())' (Of course, in a script you would write that command in a more readable way instead of trying to squeeze it all on a single line.) Best regards Oliver PS: Of course, if you really need the last percent of speed, then you should write your own specialized tool in C. -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd "FreeBSD is Yoda, Linux is Luke Skywalker" -- Daniel C. Sobral
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808261239.m7QCd3cp029363>