GREP: Trivia
On the server (OpenSolaris 2009.06)…
time /usr/bin/grep XXX /tmp/xxx.txt > /dev/null
real 0m0.039s
user 0m0.031s
sys 0m0.008s
time /usr/gnu/bin/grep XXX /tmp/xxx.txt > /dev/null
real 1m22.448s
user 1m22.364s
sys 0m0.027s
And…
/usr/gnu/bin/grep –version
grep (GNU grep) 2.5
Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
So, on my desktop (Ubuntu 8.04)…
time /bin/grep XXX /tmp/xxx.txt > /dev/null
real 0m0.049s
user 0m0.044s
sys 0m0.004s
/bin/grep –version
GNU grep 2.5.3
Copyright (C) 1988, 1992-2002, 2004, 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
…
And on OpenSolaris the default grep is the gnu… WTF???
Wow. That’s really really bad. I know that some people are addicted to GNU stuff, but sometimes our ancient legacy bits work better. This is one of those cases. I think switching to GNU grep is a mistake here — unless someone can update the GNU bits. (Note that Sun grep is only about 405 lines of code, which is relatively tiny.)
The thing is, someone decided that /usr/gnu ought to be in people’s paths first. I guess because people griped that Solaris isn’t Linux. (Duh!) So by putting /usr/gnu first, we give people access to all the GNU commands by default, irrespective of whether a given command is better (or worse, or much worse!) in GNU than in /usr/bin. But hey, it has the same command line switches as Linux, right? (The fact that the entire domain of UNIX vendors has pretty much abdicated all design for these utilities to whoever wants to do the work for the FSF/Gnu utilities is another sore point with me — its one of the few really bad consequences, IMO, of open source software. Vendors get lazy and just slurp up whatever garbage other people have produced and real innovation stemming from competition in those areas basically evaporates. Bummer.)
This whole “familiarity” kneejerk response is one that I’ve been rather unhappy with for a long time. But hey, at least users like me can override their default path to leave /usr/gnu where it properly belongs — not in my $PATH at all!
agree
wc -l /tmp/xxx.txt
106656 /tmp/xxx.txt
;-)
try LC_ALL=C /usr/bin/gnu/grep XXX ….
Wow!!!
time LC_ALL=C /usr/gnu/bin/grep XXX /tmp/xxx.txt
real 0m0.029s
user 0m0.023s
sys 0m0.006s
And the winner is… ;-)
Thanks Robert!
That explains, but not justifies.