Get current directory absolute path from a bash script

Get current directory absolute path from a bash script

To get the absolute dir of the executing script

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

For sh:

DIR=$(cd "$(dirname "$(readlink -f "$0")")" >/dev/null 2>&1 && pwd)
Buy Me A Coffee