title: bash determine if variable is empty and if so exit.
body: <p>I am trying to perform this: 
  i have a test file which md5sum of files located on sftp. 
  variables should contain an md5sum (string), if the variable is empty it means there is no file on the sftp server. 
  i am trying this code but it does not work..</p>
  
  <pre><code>    if [ -z $I_IDOCMD5 ] || [ -z $I_LEGALMD5 ] || [ -z $I_ZIPMD5 ]
  then
          echo "ERROR: At least one file not present of checksum missing no files will be deleted" &gt;&gt;$IN_LOG
          ERRORS=$ERRORS+2
  else
   if [[ $I_IDOCMD5 == $($DIGEST -a md5 $SAPFOLDER/inward/idoc/$I_IDOC) ]]
     then
          echo "rm IDOC/$I_IDOC" &gt;/SAP/commands_sftp.in
     else
          echo "problem with checksum"
          ERRORS=$ERRORS+2
   fi
  
   if [[ $I_LEGALMD5 == $($DIGEST -a md5 $SAPFOLDER/inward/legal/$I_LEGAL) ]]
     then
          echo "rm LEGAL/$I_LEGAL" &gt;&gt;/SAP/commands_sftp.in
     else
          echo "problem with checksum"
          ERRORS=$ERRORS+2
   fi
  
   if [[ $I_ZIPMD5 == $($DIGEST -a md5 $SAPFOLDER/inward/zip/$I_ZIP) ]]
     then
          echo "rm ZIP/$I_ZIP" &gt;&gt;/SAP/commands_sftp.in
     else
          echo "problem with checksum"
          ERRORS=$ERRORS+2
  fi
  </code></pre>