Mike Miller wrote:
> On Wed, 27 Feb 2008, Kathryn Hogg wrote:
>
>> If you want to print just the directory that the script is located in do
>>
>> (cd $(dirname $0); pwd)
>
> That assumes that the script is in "dirname $0" but what if the script is
> in /usr/local/bin and /usr/local/bin is in the path and the user typed
> this:
>
> script.bash

If I put the script in a directory in my search path and then run the
script without a pathname, $0 is set to the full path name to the
executable.  So dirname $0 works.

I'm using bash 3.2.33 on fedora 8 and I'm pretty sure that ksh has worked
like this on various unix implementations (hp-ux, solaris, aix, tru64) for
many years.

-- 
Kathryn
http://womensfooty.com