title: Bash Shell Script - Check for a flag and grab its value
body: <p>I am trying to make a shell script which is designed to be run like this:</p>
  
  <pre><code>script.sh -t application
  </code></pre>
  
  <p>Firstly, in my script I want to check to see if the script has been run with the -t flag. For example if it has been run without the flag like this I want it to error:</p>
  
  <pre><code>script.sh
  </code></pre>
  
  <p>Secondly, assuming there is a -t flag, I want to grab the value and store it in a variable that I can use in my script for example like this:</p>
  
  <pre><code>FLAG="application"
  </code></pre>
  
  <p>So far the only progress I've been able to make on any of this is that $@ grabs all the command line arguments but I don't know how this relates to flags, or if this is even possible.</p>