From owner-freebsd-questions@FreeBSD.ORG Tue Aug 26 12:39:06 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 9AE36106566C for ; Tue, 26 Aug 2008 12:39:06 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (unknown [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id 255778FC19 for ; Tue, 26 Aug 2008 12:39:05 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.2/8.14.2) with ESMTP id m7QCd31u029364; Tue, 26 Aug 2008 14:39:04 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.2/8.14.2/Submit) id m7QCd3cp029363; Tue, 26 Aug 2008 14:39:03 +0200 (CEST) (envelope-from olli) Date: Tue, 26 Aug 2008 14:39:03 +0200 (CEST) Message-Id: <200808261239.m7QCd3cp029363@lurza.secnetix.de> From: Oliver Fromme To: freebsd-questions@FreeBSD.ORG, walt@wump.org In-Reply-To: X-Newsgroups: list.freebsd-questions User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.3-STABLE (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Tue, 26 Aug 2008 14:39:04 +0200 (CEST) Cc: Subject: Re: sed/awk, instead of Perl X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-questions@FreeBSD.ORG, walt@wump.org List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Aug 2008 12:39:06 -0000 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