I'm trying to find a variable or a command that will tell me where the currently executing script lives. So, If I'm running /foo/bar.sh, I'm looking for a something that will give me "/foo/", while I'm inside the script bar.sh. On windows, this is "%~dp0". On linux, `pwd` isn't right all the time, because it tells the location the script was executed from, not where it lives. $0 is not normalized, it can have all sorts of interesting paths in it. The best I have come up with so far is: PROG=`which $0` PROGDIR=`dirname $PROG` echo $PROGDIR But I'm not yet convinced that this will always work. Is there an easier way to do this? Thanks, Dan