Questions Tagged With scripthttp://linuxexchange.org/tags/script/?type=rssquestions tagged <span class="tag">script</span>enThu, 30 Dec 2010 17:12:19 -0500Is there a way to search a file looking for two or more words that appear in the file?http://linuxexchange.org/questions/1467/is-there-a-way-to-search-a-file-looking-for-two-or-more-words-that-appear-in-the-file<p>I'm looking to "grep" a file looking for matches only if 2 or more of the keywords are found.</p> <p>So, for example, I want to search a file for blah and foo but they are on separate lines of the file. I only want to know if the file contains both keywords. I realize grep may not be the solution for this; may need to write a script of some sort but grep or some equivalent would be much faster.</p> <p>More Info:</p> <p>I have a file that contains:</p> <pre><code>stuff blah explore morestuff explore here foo </code></pre> <p>I want to be able to search that file for to see if both blah and foo appear in the file.</p>AndyThu, 30 Dec 2010 17:12:19 -0500http://linuxexchange.org/questions/1467/is-there-a-way-to-search-a-file-looking-for-two-or-more-words-that-appear-in-the-filescriptbashsearch-files