Hacker News new | more | comments | ask | show | jobs | submit login

I would like to know what version of grep is being used? GNU or BSD grep? My money is that it is a OSX box with BSD grep.[1]

Using a clone of linus' kernel on a six year old amd64 box running debian/sid:

  (master):dfc@fob-xray:~/lk$ time git grep "leap second" > /dev/null

  real    0m0.739s
  user    0m0.540s
  sys     0m0.650s
  (master):dfc@fob-xray:~/lk$ time grep -r --exclude-dir=.git "leap second" . > /dev/null

  real    0m0.833s
  user    0m0.400s
  sys     0m0.430s
  (master):dfc@fob-xray:~/lk$ du -sh .
  1.4G    .

[1] http://lists.freebsd.org/pipermail/freebsd-current/2010-Augu...


After running a test on a Mac mini with 10.8.4 and a clone of the same repository I am overly confident that the title should be "BSD grep too slow? Use git-grep or GNU grep":

  jumbo:lk dfc$ purge ; time grep -r --exclude-dir=.git "leap second" . > /dev/null

  real	1m8.479s
  user	0m32.229s
  sys	0m2.348s
  jumbo:lk dfc$ purge ; time ggrep -r --exclude-dir=.git "leap second" . > /dev/null

  real	0m41.844s
  user	0m1.682s
  sys	0m6.035s
  jumbo:lk dfc$ purge ; time git grep "leap second" > /dev/null

  real	0m37.325s
  user	0m1.423s
  sys	0m4.213s
  jumbo:lk dfc$ gdu -sh .
  1.3G	.
You can read `ggrep` as either GNU grep or good grep.

Well shoot. `brew install grep` is is then.

And there's also ack, and ag... no shortage of options that are better than BSD grep, apparently.

It's not "WOW GNU grep is fast!" it's, "wow, BSD grep is slow."


Which is why that reference has been included in my comment from the beginning.

Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact