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?
If both the scripts are in the same directory and you got the
./foo.sh: No such file or directoryerror then the most likely cause is that you ran the first script from a different directory than the one where they are located in. Put the following in your first script so that the call tofoo.shworks irrespective of where you call the first script from: