Using grep in OSX Terminal

Continuing the story of ditching TextMate, after switching over to Vim, I was still using textmate's search project function, which I found helpful searching through hundreds of module folders and theme folders for larger projects. But, heh, besides the fact that my trial was expired, it is silly to be running another program just for a basic search. Especially when terminal does the same thing.

You can use grep to search for words in files and have them spit out a line number too :) As well as a bunch of other options:

grep --h

Will give you a list of options, but I'll list what I use:

grep -r -i -n "text" /folder/*

This searches "text" in the specified folder (Folder) and all recursive folders (-r). The results aren't case sensitive (-i) and spits out the line number of the file it finds it in (-n).