Calculate full path from PWD and relative path in shell (substituting links)
<p>I need to calculate the full path to some file for a file given a relative path from the current directory.</p>

<p><code>realpath</code> or <code>cygpath</code> (I'm on Cygwin, but this should apply to all *nix) does not work since I have a symbolic link in the path.</p>

<p>Is there an easy way to do "arithmetic" with path strings in bash/sh?</p>

<p>In essence I want to do</p>

<pre><code>/home/me/dir + ../../you/folder = /home/you/folder
</code></pre>

<p>EDIT: bad question from me, asked for one thing and then for a problem detail in one solution.</p>

<p>I have
    /there
    /there/a
    /there/a/file
    /here/b -> symbolic link to ../there/a</p>

<p>With CWD=/here, I want the answer to the question "What is the canonical path to 'b/file'?" to be "/there/a/file".</p>