I am trying to obtain the absolute path to the currently running script on OS X.
I saw many replies going for readlink -f $0. However since OS X\'s
readlink -f $0
This seems to work for OSX, doesnt require any binaries, and was pulled from here
function normpath() { # Remove all /./ sequences. local path=${1//\/.\//\/} # Remove dir/.. sequences. while [[ $path =~ ([^/][^/]*/\.\./) ]]; do path=${path/${BASH_REMATCH[0]}/} done echo $path }