CLI
How a BASH Script Can Find Its Own Location
Most foolproof method I'm aware of is the following: SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd && echo x)" SCRIPTDIR="${SCRIPTDIR%x}" or if you're not worried about newlines at the end of your directory names: SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" How does this work? In the first example