title: Bash: Check all values of an associative array is equal to
body: <p>I have an associative array that is dynamically created. I don't know how many items there will be or what their names will be but this is an example I have created:-</p>
  
  <pre><code>declare -A MDARRAY
  MDARRAY[md126]="clean"
  MDARRAY[md127]="degraded"
  </code></pre>
  
  <p>I would like to compare the value of each array item against a couple of strings. For example, the required result would be similar to :-</p>
  
  <pre><code>if [ "$MDARRAY[md126]" != "clean" || "$MDARRAY[md126]" != "active" &amp;&amp; "$MDARRAY[md127]" != "clean" || "$MDARRAY[md127]" != "active" ]; then
  ...
  else
  ...
  fi
  </code></pre>
  
  <p>If there were 5 array items it would check all 5 and if any one of them doesn't equal 'clean' or 'active' the first code block would match else the second.</p>
  
  <p>Hope this makes sense.</p>