Although you are looking for a GUI solution, I would like to share a command line solution, because I think it is quite handy and easy to use:
tl;dr:
- Use
grep -w methyldopa *.tex | cut -d":" -f1 if all files are in the same directory.
- Use
find -name "*.tex" -exec grep -H -w methyldopa {} \; | cut -d":" -f1 in a directory, where all files sou want to find are in subdirectories.
- Edit: Shortest Way (credits to @A.B.):
grep -rwl methyldopa | grep .tex
long version with explanations:
First Case:
All files, you want to search are in the same directory.
This is the easiest scenario. You can simply use
grep -w methyldopa *.tex | cut -d":" -f1
to find all .tex files containing methyldopa.
Explanation:
Directory and file content:
file1.txt
file2.txt
file3.list
#file1.txt
foo
bar
foobar
#file2.txt
foo
foobar
1337
#file3.list
foo
bar
foobar
Now, you can use grep foo * to search for foo in all files. This is waht you will get:
file1.txt:foo
file1.txt:foobar
file2.txt:foo
file2.txt:foobar
file3.list:foo
file3.list:foobar
Using the -w option, will prevent finding foobar:
grep -w foo *
file1.txt:foo
file2.txt:foo
file3.list:foo
If you want to restrict your search to files with a special ending, you can do the following:
grep -w foo *.txt
file1.txt:foo
file2.txt:foo
Last, but not least, you can pipe the results to a cut command to extract only the filenames (-d":" sets the field separator to :, -f1 returns the first field of each line):
grep -w foo *.txt | cut -d":" -f1
file1.txt
file2.txt
Second Case:
Your files are in different directories. In this case, you should use find to find the files first:
find -name "*.txt" -exec grep -H -w foo {} \; | cut -d":" -f1
Explanation:
find -name "*.txt" searches for files ending with .txt in your current directory and all subdirectories. You can use something like find ~/Documents/ -name "*.txt" to start searching at ~/Documents.
-exec grep -H -w foo {} \; searches for foo in each file that was found and returns something like this (the -H flag makes sure, that the filename is printed):
./testdir/file2.txt:foo
./testdir/file1.txt:foo
Like in the first case, | cut -d":" -f1 cuts out the filenames from the output.