Este fragmento de script bash deve ajudar
# get the path to the currently running script:
self=$0
# test if $self is a symlink:
if [ -L $self ] ; then
# readlink returns the path to the file the link points to:
target='readlink $self'
else
target=$self
fi
# strip off the script name from the path:
path='dirname $target'
# $path/mylib.sh now points to the mylib.sh
# file in the folder where the original script is:
source $path/mylib.sh