title: Use grep --exclude/--include syntax to not grep through certain files
body: <p>I'm looking for the string <code>foo=</code> in text files in a directory tree. It's on a common Linux machine, I have bash shell:</p>
  <pre><code>grep -ircl &quot;foo=&quot; *
  </code></pre>
  <p>In the directories are also many binary files which match <code>&quot;foo=&quot;</code>. As these results are not relevant and slow down the search, I want grep to skip searching these files (mostly JPEG and PNG images). How would I do that?</p>
  <p>I know there are the <code>--exclude=PATTERN</code> and <code>--include=PATTERN</code> options, but what is the pattern format? The man page of grep says:</p>
  <pre><code>--include=PATTERN     Recurse in directories only searching file matching PATTERN.
  --exclude=PATTERN     Recurse in directories skip file matching PATTERN.
  </code></pre>
  <p>Searching on <em>grep include</em>, <em>grep include exclude</em>, <em>grep exclude</em> and variants did not find anything relevant</p>
  <p>If there's a better way of grepping only in certain files, I'm all for it; moving the offending files is not an option. I can't search only certain directories (the directory structure is a big mess, with everything everywhere). Also, I can't install anything, so I have to do with common tools (like <em>grep</em> or the suggested <em>find</em>).</p>