PDA

View Full Version : Linux bash script, discover script path and put into variable



Fli
05-31-2015, 04:16 PM
How an bash script is able to discover self path (path in which it is placed)?

Here is one way:

# cat /path/to/script


DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
echo $DIR

# /path/to/script


/path/to