Thursday, July 2, 2009

Get the Canonical Pathname of a Directory or File in OS X, Linux, Unix, *nix

This solution is from:

cd -P -- "$(dirname -- "SOMETHING")" && printf '%s\n' "$(pwd -P)/$(basename -- "SOMETHING")"
Where SOMETHING could be $JAVA_HOME, some other env. var, or pretty much any file or directory path of which you want to find the actual (canonical) path.

No comments: