Skip to content

Instantly share code, notes, and snippets.

@cesarmiquel
Created July 19, 2017 01:35
Show Gist options
  • Save cesarmiquel/069136b683b674c94bd9f44437f3ec74 to your computer and use it in GitHub Desktop.
Save cesarmiquel/069136b683b674c94bd9f44437f3ec74 to your computer and use it in GitHub Desktop.
Determine the path of the running script in Bash.
#!/bin/bash
#
# Get path to this script:
# http://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
#
pushd `dirname $0` > /dev/null
SCRIPT_PATH=`pwd -P`
ROOTFS=`dirname "$SCRIPT_PATH"`
popd > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment