get script's directory location ala $0

Posted on 2006-06-09
Medium Priority
Last Modified: 2008-03-10

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.

Question by:Marketing_Insists
LVL 23

Accepted Solution

brettmjohnson earned 1200 total points
ID: 16872385
use the dirname command:
 dirname $0


Author Comment

ID: 16874553
Sorry, somehow posted to wrong group :)

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.

Join & Write a Comment

This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
This article describes and provides a custom-made tool I wrote to give businesses a means of identifying commercial music content, without having to expend too much effort. Business recordings are easily identified from possibly illegal music files …
Introduction to Processes

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question