title: How to check if a directory exists within a given path
body: <p>I'm creating a simple script for backing up and I want to check if a directory exists in a given path like so:</p>
  
  <pre><code>fullPath=/usr/local/webapps/mydir
  
  if mydir exists in my $fullPath
  
      then back it up
      else give error
  fi
  </code></pre>
  
  <p>My question is how do I formulate the if statement to check if the last directory exists in the <strong>$fullPath</strong> variable? Just to clarify, for this case it would be <strong>mydir</strong> if I used /usr/local it would be <strong>local</strong> etc.</p>
  
  <p>Thanks in advance!</p>