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