When executing a bash script in the Linux Terminal, is there a difference between "
bash foo.sh" and "
./foo.sh"? Or are they just two different ways of performing the same function?
They are likely equivalent if
- is executable, and
- begins with with
Otherwise, and given the precondition you describe (
foo.sh is a bash script), the
./foo.sh version may well fail, either because it doesn't have execute permission for the user, or because it is interpreted by
/bin/sh instead of
/bin/sh is the default script interpreter).