title: how to use getopt(s) as technique for passing in argument in bash
body: <p>Can someone show me an example how to use getopts properly or any other technique that I would be able to pass in an argument? I am trying to write this in unix shell/bash. I am seeing there is getopt and getopts and not sure which is better to use. Eventually, I will build this out to add for more options. </p>
  
  <p>In this case, I want to pass the filepath as input to the shell script and place a description in the case it wasn't entered correctly.</p>
  
  <pre><code>export TARGET_DIR="$filepath"
  </code></pre>
  
  <p>For example: (calling on the command line)</p>
  
  <pre><code>./mytest.sh -d /home/dev/inputfiles
  </code></pre>
  
  <p>Error msg or prompt for correct usage if running it this way:</p>
  
  <pre><code>./mytest.sh -d /home/dev/inputfiles/
  </code></pre>