Wednesday, September 26, 2012

Get script's own directory in bash script

It was always a problem for me to get the directory the called script is stored in, in the script itself. Thanks to this SO question (http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in) it's not a problem anymore. As it says:
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Or, to get the dereferenced path (all directory symlinks resolved), do this:
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

1 comment:

kalilwaack said...

What is the safest place to play slots? | JTM Hub
With so many types of 여주 출장안마 casino games, 고양 출장안마 each game is worth one page. You will never find an 원주 출장마사지 online 울산광역 출장안마 casino 남양주 출장마사지 that has to be on the