If you need to get the script directory of an executed bash script you can use the following snippet to cd to the script directory:
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR" || exit 1
If you need to get the script directory of an executed bash script you can use the following snippet to cd to the script directory:
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$DIR" || exit 1