An excerpt from the grep man page
If the first few bytes of a file indicate that the file contains binary data, assume that the file is of
type TYPE. By default, TYPE is binary, and grep normally outputs either a one-line message saying that a
binary file matches, or no message if there is no match.
This is the default behavior. You will only concern about searching into "all files in all directories ". You can use something like
find / -type f -print 0 | xargs -0 grep <pattern>
This will search <pattern> into all files on your system. It may take a lot of time and resources, anyway. Better to run as root in order to avoid file access permissions problems.