get script's directory location ala $0

If $0 gives the location of the script, how can I get the directory the script is located?

CWD; doesn't work the I want, since if I execute a script located on a network drive from the commandline on my local PC, the working directory would be whatever directory I'm in at my shell.

Who is Participating?
brettmjohnsonConnect With a Mentor Commented:
use the dirname command:
 dirname $0

Marketing_InsistsAuthor Commented:
Sorry, somehow posted to wrong group :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.