title: Shell: Checking if argument exists and matches expression
body: <p>I'm new to shell scripting and trying to write the ability to check if an argument exists and if it matches an expression. I'm not sure how to write expressions, so this is what I have so far:</p>
  
  <pre><code>#!/bin/bash
  
  if [[ -n "$1"] &amp;&amp; [${1#*.} -eq "tar.gz"]]; then
    echo "Passed";
  else 
    echo "Missing valid argument"
  fi
  </code></pre>
  
  <p>To run the script, I would type this command: </p>
  
  <pre><code># script.sh YYYY-MM.tar.gz
  </code></pre>
  
  <p>I believe what I have is</p>
  
  <ol>
  <li>if the YYYY-MM.tar.gz is not after script.sh it will echo "Missing valid argument" and</li>
  <li>if the file does not end in .tar.gz it echo's the same error. </li>
  </ol>
  
  <p>However, I want to also check if the full file name is in YYYY-MM.tar.gz format.</p>