For the complete documentation index, see llms.txt. This page is also available as Markdown.

Directory of script

It's often useful to know the path of the script being executed, e.g. for sourcing other files.

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

This solution works as long as the last component of the path used to find the script is not a symlink.

Source: stackoverflow

Last updated