title: Is there no unless in shell script?
body: <p>I tried to do the opposite of if in shell to only do something if a value in a hash doesn't exist. I've learned to create a hash in bash from here:<a href="https://stackoverflow.com/questions/688849/associative-arrays-in-shell-scripts">Associative arrays in Shell scripts</a></p>
  
  <pre><code>declare -A myhash
  </code></pre>
  
  <p>I declared a simple hash:</p>
  
  <pre><code>myhash[$key]="1"
  </code></pre>
  
  <p>and </p>
  
  <pre><code>[ ${myhash[$key]+abc} ]
  </code></pre>
  
  <p>to see if myhash[$key] exist or not from here: <a href="https://stackoverflow.com/questions/13219634/easiest-way-to-check-for-an-index-or-a-key-in-an-array?answertab=active#tab-top">Easiest way to check for an index or a key in an array?</a></p>
  
  <p>I also learned to add ! in front of an expression to do the opposite in if clause from here:<a href="https://stackoverflow.com/questions/10552711/how-to-make-if-not-true-condition">How to make &quot;if not true condition&quot;?</a></p>
  
  <p>But the following expression</p>
  
  <pre><code>if ! [ ${myhash[$key]+abc} ]; then
       echo $key
  
  fi
  </code></pre>
  
  <p>doesn't work and no information is printed. There is no error message. </p>
  
  <p>I tried this:</p>
  
  <pre><code>[ ${myhash[$key]+abc} ] &amp;&amp; echo $key
  </code></pre>
  
  <p>And got the error message:</p>
  
  <pre><code>abc: command not found
  </code></pre>
  
  <p>Can anyone tell me how to make it work?</p>