title: how to check for multiple strings in 'if-then-else-fi' in linux?
body: <p>I have a file named 'testfile', which contains:</p>
  
  <pre><code>Computer Science   123 Congress Street,
  Biology            2 New York Ave,
  Graduate Center    1 New York Ave
  </code></pre>
  
  <p>And I have a <em>script</em> named 'search' as follows :</p>
  
  <pre><code>grep $* testfile
  ____________________                 # line 2
  then echo "there is a match"         # message 1
  else echo "no such department found" # message 2
  fi
  </code></pre>
  
  <p>It should print "there is a match" for 'Computer Science', 'Biology' and 'Graduate Center' departments. And "no such department found" if none of the above departments.</p>
  
  <p>So I am trying on #line2.
  I have few questions regarding this :</p>
  
  <p>(1) Is it possible to write 'grep' again inside of 'if' ? for e.g. can I write like this       </p>
  
  <blockquote>
    <p><em>if grep -q Biology "$testfile"</em></p>
  </blockquote>
  
  <p>. And if yes how can I test for all the strings(in this case 'departments') ?</p>
  
  <p>(2) I know if I used only grep to find multiple strings I say</p>
  
  <blockquote>
    <p><em>grep 'string1\|string2\|string3' PATH</em></p>
  </blockquote>
  
  <p>OR</p>
  
  <blockquote>
    <p><em>egrep -w 'string1|string2' PATH</em></p>
  </blockquote>
  
  <p>But can I use this kind of format in if statement ? If yes , how ?</p>
  
  <p>(3)
  Is it possible to do this way? :</p>
  
  <blockquote>
    <p><em>if ["$"=="Computer Science"] || ["$"=="Biology"] || ["$"=="Graduate Center"]</em></p>
  </blockquote>
  
  <p>Can anyone please help me to clarify my doubts ?</p>