Created
April 23, 2018 16:14
-
-
Save dmrub/68510da8c67f0551b4df2a5cf3e9b616 to your computer and use it in GitHub Desktop.
How to get directory path of a shell script in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
THIS_DIR="$(dirname "$(readlink -f "$BASH_SOURCE")")" | |
THIS_DIR=$( (cd "$(dirname -- "$BASH_SOURCE")" && pwd -P) ) | |
THIS_DIR=$(dirname "$( readlink -f "${BASH_SOURCE}" 2>/dev/null || \ | |
python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "${BASH_SOURCE}" )") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment