title: how to check for the presence of two words in a file using GREP
body: <p>I have two files A.txt and B.txt containing two lists respectively as shown bellow.</p>
  
  <p>File A.txt</p>
  
  <pre><code>hello
  hi 
  ko
  </code></pre>
  
  <p>File B.txt</p>
  
  <pre><code>fine
  No 
  And how
  why
  </code></pre>
  
  <p>Now I want to check presence of any of these words (from A.txt AND B.txt) in a line in another file C.txt.</p>
  
  <p>I am using the grep command </p>
  
  <pre><code>grep -iof A.txt C.txt| grep B.txt
  </code></pre>
  
  <p>C.txt contains sentences containing words from A.txt and B.txt</p>
  
  <pre><code>Hello I am fine
  I am not fine
  why ko is and how?
  </code></pre>
  
  <p>doesn't show any output</p>
  
  <p>So, now I want if any word from A.txt and B.txt present simultaneously in one sentence it should show the output as</p>
  
  <pre><code>Hello fine
  why ko and how 
  </code></pre>
  
  <p>To print only the matching words from both files if they occur simultaneously in C.txt, instead of printing the whole line from C.txt</p>