title: How to find the deepest path that exists in Bash
body: <p>When I get an error like:</p>
  
  <pre><code>$ ls /var/django-projects/daks/public/media/uploads/bandsaws/sneaks.jpg
  ls: /var/django-projects/daks/public/media/uploads/bandsaws/sneaks.jpg: No such file or directory
  </code></pre>
  
  <p>I'd like to be able to ask <code>what-is-the-deepest-path-that-does-exists</code> and get back, say:</p>
  
  <pre><code>/var/django-projects/daks/public/media/
  </code></pre>
  
  <p>I think it could be done with a loop that added <code>../</code> on each iteration and quitted when a path that exists was found.</p>