On Wed, 27 Feb 2008, Jon Schewe wrote:

> On Linux you have two options:
> 1) If you can guarantee that dirname exists then this works:
> mypath=`dirname $0`

That won't work when there are spaces in $0 -- see my earlier message.

> cd ${mypath}

That won't work when there are spaces in $mypath.


> 2) If you're not sure that dirname exists, this works well:
> mypath="`echo $0 | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`"

That doesn't find the path to the file, it just takes the path that is 
given, but if the path isn't given, it fails.

See my earlier message and the original posting.


> cd ${mypath}

Again, that won't work when there are spaces in $mypath.

Mike