title: bash cd up to specific directory
body: <p>I'm working on an install script (written in bash) for a library.  The install script lives in a subdirectory of the project's base directory.  I'd like users to be able to run the install script from anywhere under the base directory, so I'm trying to make the script <code>cd</code> to the base directory before executing other commands.</p>
  <p>I'm looking at something like</p>
  <pre><code>while [[ $PWD == *&quot;ProjectName&quot;* ] &amp;&amp; [ $PWD -ne *&quot;ProjectName&quot; ]]; do cd .. ;done
  </code></pre>
  <p>I'm open to cleaner solutions, but at the very least I'd like to understand why the above does not work.  No doubt I have brackets in the wrong spots, but I'm not sure where to put them.</p>