Skip to content

Instantly share code, notes, and snippets.

@bgromov
Created June 23, 2016 16:22
Show Gist options
  • Save bgromov/93da2ff0d2b095571fa15eb0baefdce9 to your computer and use it in GitHub Desktop.
Save bgromov/93da2ff0d2b095571fa15eb0baefdce9 to your computer and use it in GitHub Desktop.
One-liner to determine scripts own location. No matter where it is called from. (Doesn't work with symlinks)
#!/bin/bash
# Credits: http://stackoverflow.com/a/246128
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Where am I?!"
echo -e "I am here: ${DIR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment