Q:

Bash: is there a way to search for a particular string in a directory of files?

Possible Duplicate:
Search for a text pattern in linux 

In bash, I was wondering if there were any commands that would let you know if a particular string you are looking for exists within the files located in the current directory you are in.
Say you are looking for the function 'toUpperCase()' within a set of C files in your current directory. There are a lot of files, so you wouldn't want to manually open each one up using vim and check for the string 'toUpperCase' because that would take a lot of time. If not a bash command line, is there another method to do this efficiently?

A:

With grep:
grep -R "toUppercase()" *

Or, if you have ack-grep installed, simply:
ack-grep "toUppercase"

If you want to limit the search in C files, with ack-grep:
ack-grep -cc "toUppercase()"

ack-grep can also be installed on OSX but the executable is called just ack.

A:

The standard text search tool is grep.
To look for the string toUpperCase( in all .c files in the current directory:
grep -F 'toUpperCase(' *.c

If you want to look in subdirectories as well:
grep -r --include='*.c' -F 'toUpperCase('

If you're looking for C function calls, then ctags may be a better fit. You run it once on all your source files to create an index of identifiers, then use your editor to navigate between calls. All vi-like editors can use ctags's TAGS file. If you use Emacs, run the similar program etags.

A:

You're using vim.  You've got a tool to do this built in.
Predictably, there are seven answers already saying to use grep.  But I seem to be the only person thus far who has noticed from your question that you are using vim.  As such, although you can use grep from within vim, you can also use vim's built-in tool.  This is invoked via the :vimgrep command.  
To search "all of the C source files in the current directory for calls to the function toUpperCase()" one types the vim command
:vimgrep "\<toUpperCase\_s*(" *.c

The resulting list of matches is automatically loaded up into the quickfix list, accessible with either of (see the on-line help for the subtle difference)
:copen
:cwin

To find the function definition, rather than calls to it, ctags is the tool, as mentioned in Gilles's answer, in conjunction with the :tjump or :tselect commands.
Why use :vimgrep?
The on-line help (:help grep) enmumerates several of the reasons, which I won't parrot here.  Further to those, compare the action of :vimgrep with that of dietbuddha's answer.  dietbuddha's command line forks an individual grep process for each individual C source file.  It doesn't even employ xargs to reduce that overhead.  And you still have to somehow parse the output to invoke your text editor on the relevant source files once it is finished.  :vimgrep doesn't fork off multiple additional processes at all, and using the result is simplicity itself.  Merely selecting one of the entries in the resultant quickfix list automatically positions the cursor on the relevant line of the relevant source file.  
In fact, it does exactly what you wrote you would do by hand, except automatically.  It's the automated way of doing those very text editor actions.  It loads up the file as if loaded by hand, searches it for a regular expression (using the same regular expression syntax that you are already using elsewhere in vim), records the places where matches occur, and then unloads the file.

