6
2
I need to write a script, which would be called from any location, but needs to run from the directory it resides in. The script should query its directory at runtime.
How can this be achieved?
Example:
- script
hello.sh
resides in/someplace/
- though it is called from
/other/place/
, - the script knows (during runtime) that it resides in
/someplace
EDIT
Additional question:
How's about the location of the script, but with symlink resolved?
Example:
- script
hello.sh
resides in/someplace/
- symlink exists to it in
/bin
- though the symlink is called from
/other/place/
, - the script knows (during runtime) that it resides in
/someplace
I suggest you move this to Stackoverflow. I think it's more related to programming than to general computing, and you might get faster and better responses there. – Nathan Fellman – 2009-10-01T21:59:24.850