get absolute path of a script

July 21, 2008

if you need the absolute path of the script you are running at the moment:

absPath=`echo -n \`pwd\` ;( [ \`dirname \$0\` == '.' ] && echo ) || echo "/\`dirname \$0\`"`

for example useful to build up libary paths in project folders.