git grep, mdfind > script/find

27 Jun 3:11pm (3 months ago) reply

in previous rails projects i’ve written, i’ve used a shell script i put in script/find that did a recursive grep on certain subdirectories that avoids .svn directories. it’s worked pretty well.

find {app,lib,config,test/unit,test/functional,test/integration,public/*} -name .svn -prune -o -type f -print0 | xargs -0 fgrep -- "$*"

lately as i’ve moved to git, i’ve started using git grep as a replacement though. it has more features than my basic find, plus i can search against the index to make it faster.

git grep search_string

it also just occurred to me that i can use mdfind on the mac which is also arguably faster since everything’s already been indexed by spotlight.

mdfind -onlyin . search_string

Edit