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.
This entry was posted on Monday, July 21st, 2008 at 12:51 pm and is filed under Bash. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
November 3, 2008 at 12:01 pm
If you need a command which handles ../ etc you can use
absPath=”$(cd $(dirname ${0}); pwd)”
execName=”${absPath}/$(basename ${0})”
Regards
Magnus
January 13, 2009 at 6:47 pm
thanks, looks much better than the version i found above..