title: Understanding a bash script
body: <p>I am new to bash and wanted to learn what this code is trying to do, if it is done poorly or with errors and how it can be improved.</p>
  <pre class="lang-sh prettyprint-override"><code>COMMAND=$1
  
  case $COMMAND in
      &quot;upgrade&quot;)
          UPSCRIPT=`ls -t ./assets/upgrade | head -n1`
          python ./assets/upgrade/$UPSCRIPT | tee &gt;&gt; biglog.txt
          VERSION=$(echo $UPSCRIPT | awk -F. '{print $1}')
          echo `date` $VERSION &gt; ./version.txt
          test -e ./artifcts &amp;&amp; rm -rf ./artifacts      
       ;;
  
      &quot;downgrade&quot;)
          DOWNSCRIPT=`ls -t ./assets/downgrade | head -n1`
          python ./assets/downgrade/$DOWNSCRIPT | tee &gt;&gt; biglog.txt 
          VERSION=$(echo $UPSCRIPT | awk -F. '{print $1}')
          echo `date` $VERSION &gt; ./version.txt
          test -e ./artifcts &amp;&amp; rm -rf ./artifacts      
      ;;
      *)
          while read -r UPSCRIPT; do
              python $UPSCRIPT | tee &gt;&gt; biglog.txt
              VERSION=$(echo $UPSCRIPT | awk -F. '{print $1}')
              echo `date` $VERSION &gt; ./version.txt
              test -e ./artifcts &amp;&amp; rm -rf ./artifacts      
          done &lt;&lt;&lt; $(find &quot;./assets/update&quot; -type f -name &quot;*.py&quot;)
  esac
  </code></pre>