Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>readlink -f "$path" </code></pre> <p><sup>Editor's note: The above works with <em>GNU</em> <code>readlink</code> and <em>FreeBSD/PC-BSD/OpenBSD</em> <code>readlink</code>, but <em>not</em> on OS X as of 10.11.<br> <em>GNU</em> <code>readlink</code> offers additional, related options, such as <code>-m</code> for resolving a symlink whether or not the ultimate target exists.</sup></p> <p>Note since GNU coreutils 8.15 (2012-01-06), there is a <strong>realpath</strong> program available that is less obtuse and more flexible than the above. It's also compatible with the FreeBSD util of the same name. It also includes functionality to generate a relative path between two files.</p> <pre><code>realpath $path </code></pre> <hr> <p>[Admin addition below from comment by <a href="/users/65889/halloleo">halloleo</a> —<a href="/users/65889/danorton">danorton] </a></p> <p>For Mac OS X (through at least 10.11.x), use <code>readlink</code> without the <code>-f</code> option:</p> <pre><code>readlink $path </code></pre> <p><sup>Editor's note: This will not resolve symlinks <em>recursively</em> and thus won't report the <em>ultimate</em> target; e.g., given symlink <code>a</code> that points to <code>b</code>, which in turn points to <code>c</code>, this will only report <code>b</code> (and won't ensure that it is output as an <em>absolute path</em>).<br> Use the following <code>perl</code> command on OS X to fill the gap of the missing <code>readlink -f</code> functionality:<br> <code>perl -MCwd -le 'print Cwd::abs_path(shift)' "$path"</code></sup></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload