Determine bash script's location from bash script


Sometimes, you need to know the current (full-path) directory of a bash script in order to launch another file relative to the bash script, instead of using global paths or the $PATH value.

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.