Last Updated: February 25, 2016
·
1.601K
· sheerun

Get reliably the absolute path of currently executed script

CWD="$( 
  cd "$(dirname "$(readlink "$0" || printf %s "$0")")"
  pwd -P 
)"

PATH="$CWD:$PATH"

source sibling.sh # source file in the same directory

This works also for linked executables.