title: Check if string is neither empty nor space in shell script
body: <p>I am trying to run the following shell script which is supposed to check if a string is neither space nor empty. However, I am getting the same output for all the 3 mentioned strings. I have tried using the "[[" syntax as well but to no avail.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>str="Hello World"
  str2=" "
  str3=""
  
  if [ ! -z "$str" -a "$str"!=" " ]; then
          echo "Str is not null or space"
  fi
  
  if [ ! -z "$str2" -a "$str2"!=" " ]; then
          echo "Str2 is not null or space"
  fi
  
  if [ ! -z "$str3" -a "$str3"!=" " ]; then
          echo "Str3 is not null or space"
  fi
  </code></pre>
  
  <p>I am getting the following output:</p>
  
  <pre><code># ./checkCond.sh 
  Str is not null or space
  Str2 is not null or space
  </code></pre>