Using Ack was frustrating experience recently. Ack had troubles finding things.
$ time ack -Ri 'cancel the remaining quantity of this line item' ./app
real 0m0.730s
user 0m0.220s
sys 0m0.137s
$ time grep -Ri 'cancel the remaining quantity of this line item' ./app
./app/views/order_line_items/_cancel_form.html.haml: Cancel the remaining quantity of this line item:
real 0m13.791s
user 0m0.282s
sys 0m0.321s
$ time git grep -i 'cancel the remaining quantity of this line item' ./app|cat
app/views/order_line_items/_cancel_form.html.haml: Cancel the remaining quantity of this line item:
real 0m1.188s
user 0m1.984s
sys 0m0.074s
As you can see Ack found nothing in 0.7 sec. Grep spent 13.8 sec yelding results first time. git-grep was the fastest to get results.
Some time ago people just switched to Ack. I did that too and did that for a reason.
Biggest problem I had with grep - inability to configure exclustion patterns for directories.
Apparently not anymore. With grep-2.6
it’s possible to configure excludes with --exclude-dir
option.
But you’re in trouble if you’re OSX user: latest grep
OSX got is version 2.5.1
$ /usr/bin/grep --version
grep (GNU grep) 2.5.1
Homebrew
to the rescue! Well, not quite true: homebrew doesn’t ship system duplicates
Why would they decide not to have grep???
Anyway back to grep. Along with compiling it from source there’s still a way to get it installed with homebrew
: just use homebrew-alt
fork:
$ brew install https://raw.github.com/Homebrew/homebrew-dupes/master/grep.rb
UPDATE: branch moved to new repo named ‘homebrew-alt’ UPDATE2: now there’s official homebrew-dupes repo
I’m back to using grep
and git-grep
.