if I have a bash script that references a directory that exists within the folder the script resides in then I call the script from somewhere else how can I know where I am to reference said directory ?
I want the the script to do something like
Code:
installedDir=`pwd`
dataDir=$installedDir"/data"
-do something with $dataDir
If I run it from . the script works fine, but if I change to a different directory and then sh /PATH/TO/SCRIPT/script.sh then $installDir is set to where I am when I ran the script not where the script is and so can not find the data folder.
I have the annoying feeling that this is just not possible and I will have to hardcode $installDir and force people to install the script in a known location.
I tried adding
but that uses the initial starting folder not the location of the script
I also examined the results of
executed inside the script, nothing even close to useful.