title: Stop Bash Script if Hive Fails
body: <p>I have a bash script that loops through a folder and processes all *.hql files. Sometimes one of the hive script fails (syntax, resource constraint, etc), instead of the script failing it will continue onto the next .hql file. </p>
  
  <p>Anyway I can stop the bash from processing the remaining? Below is my sample bash:</p>
  
  <pre><code>for i in `ls ${layer}/*.hql`; do
        echo "Processing $i ..."
        hive ${hiveconf_all} -hiveconf DATE=${date} -f ${i} &amp;
      if [ $j -le 5 ]; then
         j=$(( j+1 ))
      else
        wait
        j=0
      fi
    done
  </code></pre>