title: using and(&&) operator in for loop in linux
body: <p>01) I am trying to use the &amp;&amp; operator in a for loop as shown below in the script. However this does not seem to work. I was not able to see the error generated in the terminal window, since it closes as soon as it runs in to an error. Could someone please tell me what I'm doing wrong?</p>
  
  <pre><code>#!/bin/bash
  
  cd ~/Documents/DTI/
  
  #subj and subj1 contain folders which are located in the DTI directory
  subj="ARN MT"
  subj1="ARNpre1 ARNpre2"
  
  for [[s in $subj] &amp;&amp; [s1 in $subj1]]
  </code></pre>
  
  <p>02) And as you can see in my "subj1", the first two entries start with the letters ARN which means that they are sub directories of ARN(located in a different place.Not in ARN main directory). So I also want to run a command in which, if subj1 contains subj then it must perform a certain command.For this purpose I wrote the following,</p>
  
  <pre><code>if [[ ${s1} == *"${s}"* ]];then
  </code></pre>
  
  <p>would this be the right way to do such operation?</p>
  
  <p>I would greatly appreciate any help.</p>
  
  <p>Thank you in advance.</p>