title: Grep to find a file that contains a string in a directory
body: <p>I'm trying to get familiar with the basics of the terminal. I'd like to find the file within my CMS website that contains my Google Analytics tracking code "gaq" as a string to search should do the trick.</p>
  
  <p>There is a folder on my desktop that contains all of the sites files. </p>
  
  <blockquote>
    <p>/Users/myname/Desktop/website</p>
  </blockquote>
  
  <p>I opened the terminal and tried</p>
  
  <pre><code>grep gaq /Users/myname/Desktop/website
  
  grep gaq * /Users/myname/Desktop/website
  </code></pre>
  
  <p>I searched on SO and Google but the internet seems crowded out with slightly more advanced uses of grep involving regular expressions and conditions.</p>
  
  <p>e.g.:
  <a href="https://stackoverflow.com/questions/4989519/unix-command-to-list-files-containing-string-but-not-containing-another-string">Unix Command to List files containing string but *NOT* containing another string</a>, <a href="https://stackoverflow.com/questions/4121803/how-can-i-use-grep-to-find-a-word-inside-a-folder">How can I use grep to find a word inside a folder?</a>.</p>
  
  <p>I thought I'd found the answer with the second example question. I tried the following command: <code>grep -nr gaq* /Users/myname/Desktop/website</code></p>
  
  <p>But that returned many results and, from what I can see, not exactly accurate matches of my search string.</p>
  
  <p>Here's a sample of the Google Analytics snippet, taken by viewing the source of the html page. My goal is to find the file that generates the analytics snippet in order to update it to the newer version of Google Analytics:</p>
  
  <pre><code>var _gaq = _gaq || [];
              _gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
              _gaq.push(['_trackPageview']);
  </code></pre>
  
  <p>So I am using "gaq" as a string to search for.</p>
  
  <p>I realize that this must sound pretty basic but it's pretty frustrating as a beginner to the shell.</p>
  
  <p>How would I search the directory /Users/myname/Desktop/website for the file (return the file not the actual paragraph of text) that contains the analytics code using grep (assuming grep is the command I should be using?)</p>