Return to Snippet

Revision: 16543
at August 7, 2009 12:05 by deepsoul


Initial Code
function canonpath () 
{ 
    echo $(cd $(dirname $1); pwd -P)/$(basename $1)
}

Initial URL

                                

Initial Description
The following shell function returns the canonicalised abolute path of a file.  It resolves symbolic links, /./ and /../ as applicable.  This was adapted from various sources.  Related snippets on snipplr are [Find absolute path of Bash script](http://snipplr.com/view/16715/find-absolute-path-of-bash-script/) and [Get current script name and absolute paths](http://snipplr.com/view/9508/get-current-script-name-and-absolute-paths/).

Initial Title
Canonical absolute path

Initial Tags
path

Initial Language
Bash