title: Automatically Download Latest WhatsApp APK using Shell Scripting
body: <p>I'm trying to create a cron job that downloads the latest version of WhatsApp's APK from their website using a bash script and make it available through my site.</p>
  
  <p>So far, I'm able to obtain the version number from the site using the following (user-agent part omitted):</p>
  
  <pre><code>wget -q -O - "$@" whatsapp.com/android | grep -oP '(?&lt;=Version )([\d.]+)'
  </code></pre>
  
  <p>And I can download the APK using the following command:</p>
  
  <pre><code>wget http://www.whatsapp.com/android/current/WhatsApp.apk
  </code></pre>
  
  <p>That part is fine. What I can't figure out is how to download the APK only if it's newer than the existing APK on the server. How should the script be?</p>
  
  <p>Since I'm not a command-line pro, I guess there's a better way to achieve this than my current approach, so if you have any suggestions, I'd appreciate it very much.</p>