how to use && with grep in bash
<p>I want to check if multiple lines in a file exist in bash. </p>

<p>so for that I use <code>grep -q</code> which works with only one line: </p>

<pre><code>if grep -q string1 "/path/to/file";then
  echo 'exists'
else
  echo 'does not exist'
fi
</code></pre>

<p>I tried many things in various combinations, for example:  </p>

<p><code>if grep -q [ string1 ] &amp;&amp; grep -q [ string2 ] "path/to/file";then</code></p>

<p>I also tried it with <code>-E</code>:</p>

<p><code>grep -E 'pattern1' filename | grep -E 'pattern2'</code></p>

<p>but nothing seems to work. Any ideas?</p>