sed/awk, instead of Perl

Oliver Fromme olli at
Tue Aug 26 12:39:06 UTC 2008

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

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:

"FreeBSD is Yoda, Linux is Luke Skywalker"
        -- Daniel C. Sobral

More information about the freebsd-questions mailing list