Skip to content

Instantly share code, notes, and snippets.


Enrico Scherlies enryco

View GitHub Profile
TheMengzor / gist:968e5ea87e99d9c41782
Created Nov 28, 2014
BASH Absolute path of current script
View gist:968e5ea87e99d9c41782
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

Is a useful one-liner which will give you the full directory name of the script no matter where it is being called from

These will work as long as the last component of the path used to find the script is not a symlink (directory links are OK). If you want to also resolve any links to the script itself, you need a multi-line solution:

while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
You can’t perform that action at this time.