title: Validating parameters to a Bash script
body: <p>I came up with a basic one to help automate the process of removing a number of folders as they become unneeded.</p>
  
  <pre><code>#!/bin/bash
  rm -rf ~/myfolder1/$1/anotherfolder
  rm -rf ~/myfolder2/$1/yetanotherfolder
  rm -rf ~/myfolder3/$1/thisisafolder
  </code></pre>
  
  <p>This is evoked like so:</p>
  
  <pre><code>./myscript.sh &lt;{id-number}&gt;
  </code></pre>
  
  <p>The problem is that if you forget to type in the <code>id-number</code> <em>(as I did just then)</em>, then it could potentially delete a lot of things that you really don't want deleted.</p>
  
  <p><strong>Is there a way you can add any form of validation to the command line parameters?</strong> In my case, it'd be good to check that a) there is one parameter, b) it's numerical, and c) that folder exists; before continuing with the script.</p>