Skip to content

Instantly share code, notes, and snippets.

@jamesadney
Created February 21, 2012 22:19
Show Gist options
  • Save jamesadney/1879413 to your computer and use it in GitHub Desktop.
Save jamesadney/1879413 to your computer and use it in GitHub Desktop.
Get the directory of a bash script
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment