Open all files containing certain text

You didn't say how you want to open them :)

One way is to use grep to recursively look for the string in your files (-r). Use -l to ask grep to output only the filenames of matching files. This will output one filename per line, use xargs to build a suitable command line for your editor.

grep -r -l foobar /foo/bar/ | xargs vim

this also works with gedit; just change vim for gedit.

You can also use find for this but it's more complicated IMHO:

find /foo/bar -type -f -exec grep -l foobar {} \;  | xargs vim

Opens files containing foobar one by one in vim:

for f in $(find /foo/bar -type f); do 
    if [ ! -z "$(grep foobar $f)" ]; then
        vim $f 
    fi
done