Your question title says "files containing" a word. However, in your question, you do mention "get the filenames containing" a word. These are different things. Fortunately, they are both rather simple, so I will simply show you both.
To find files containing a word:
grep -iR "word1" .
The -i says to ignore case. The -R is recursive (meaning sub-directories are searched). (Capital letter is documented by OpenBSD and more similar to ls, so I prefer that over -r.) The period specifies where to start looking.
To find filenames containing a word:
find . -iname "word1"
The -iname is a case-insensitive version of "name".
The period specifies where to start looking. The current directory is often a good choice.
Note: You referenced "." in one of your examples. That was great for DOS, and typically good in Microsoft Windows, but is a really bad habit for Unix environment. Seeing that makes me think you're familiar with Windows. Well, understand that in Windows, "FIND" (or "find") locates text in files. Unix is different: "grep" locates text in files, and "find" locates filenames.
Now, to exclude word 99, and to place that in a text file, add the following text:
| grep -v word99 >> output.txt
This is the pipe key, almost always Shift-Backslash.
So, as an example, if you wanted to do both, use:
grep -iR "word1" . | grep -v word99 >> output.txt
find . -iname "word1" | grep -v word99 >> output.txt
The part before the pipe character will run a command, and send the output into a Unix-style pipe. Then, the content gets sent from the pipe into the next command's standard input. grep -v will look at the standard input it receives, and exclude what you want. grep -v will send the remaining results to its standard output. The >> will redirect the prior command's standard output to the end of the specified text file.
The reason why you don't see documented options in the "find" command, about how to exclude text, is that Unix was very heavily designed with this idea of making simpler programs, and using the piping technique to cause elaborate effects. In the Microsoft environments, old Microsoft code was particularly more cumbersome with pipe-handling, so programs basically tried to incorporate more functionality into each program. On one hand, that seems simpler for the end user (having everything built-in), but that approach lacks consistency. When you're using Unix, don't be afraid of the piping: once you get used to it, you may find it simplifies things greatly, but cause you can use your simple tools in many situations, and so you don't need to re-learn simple techniques over and over (for each different program).
1
grep -r … *
is almost always better writtengrep -r … .
. The asterisk version gets ugly if there are too many files in the current directory, etc. – Eric – 2016-08-25T01:44:58.713