title: How to check if $? is not equal to zero in unix shell scripting?
body: <p>I have a script which uses test command to check if <code>$?</code> (return code of last executed command) is not equal to zero. The code is as follows: -</p>
  
  <p><code>$?</code> is the exit status of the last command executed.</p>
  
  <pre><code>if (test $? -ne 0)
  then
  //statements//
  fi
  </code></pre>
  
  <p>However this way of validation does not work for strings as get syntax error . Please suggest a suitable alternative to this. </p>