How do I refer to the current directory in a shell script?
So I have this script which calls another script in the same directory:
#! /bin/sh
#Call the other script
./foo.sh
# do something ...
For this I got ./foo.sh: No such file or directory
So I changed it to:
#! /bin/sh
#Call the other script
foo.sh
# do something ...
But this would call the foo
script which is, by default, in the PATH. This is not what I want.
So the question is, what's the syntax to refer ./
in a shell script?
./
means the current working directory, not the directory that stores the currently executing script file. I'm not sure of any mechanism to get the directory containing the currently executing script. But if your first script is in thePATH
, then so is the second script...