Skip to content

Instantly share code, notes, and snippets.

@jarryDk
Created December 17, 2024 07:30
Show Gist options
  • Save jarryDk/89a7ae464acb4d321217eed4c7cab3ad to your computer and use it in GitHub Desktop.
Save jarryDk/89a7ae464acb4d321217eed4c7cab3ad to your computer and use it in GitHub Desktop.
Get the directory where a Bash script is located from within the script itself
#!/usr/bin/env bash
#
# Get the directory where a Bash script is located from within the script itself
#
# https://stackoverflow.com/questions/59895/how-do-i-get-the-directory-where-a-bash-script-is-located-from-within-the-script#246128
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment