For a shell script to determine its own location, you can use this code snippet. It takes relative and absolute paths into account.
#!/bin/bash if [[ $0 == '/'* ]]; then MYLOCATION="`dirname $0`" else MYLOCATION="`pwd`"/"`dirname $0`" fi echo "My location is: $MYLOCATION"