Reputation: 1669
I'm calling /location2/script2.sh
from /location1/script1.sh
. Is there a method to figure out location1
from script2.sh
?
bash /location2/script2.sh
Upvotes: 1
Views: 117
Reputation: 42107
Yes, just use $PWD
or pwd
.
If you call /location2/script2.sh
from /location1/script1.sh
, then the current working directory of script2.sh
will always be /location1
, not /location2
.
Upvotes: 3