Come to discuss on the forum! ■ FAST and FREE signup. ■ |
😀 Access to discussion forums 😀 |
Help for HOMEWORKS, support in COMPUTER SCIENCE, help for learning FRENCH and ENGLISH, discussion on your INTERESTS and HOBBIES... |
Different ways to run a script
There exist several ways to run a script in a shell.
./ means the current directory. It is necessary to specify it because usually the current directory is not in the $PATH variable.
Execute 'script' if the file is executable and located in a directory listed in the $PATH variable:
Source 'script' :
The file does not need to be executable but must be a valid shell script. The file can be in the current directory or a directory listed in the $PATH variable.
Source 'script' (syntax variant) :
'source' is an alias of the command '.' defined by bash and other shells.
However, executing a script and sourcing a script are two different operations: Difference between "execute" a script and "source" a script.
- Execute 'script' if it is executable and located in the current directory:
./script
./ means the current directory. It is necessary to specify it because usually the current directory is not in the $PATH variable.
script
source script
The file does not need to be executable but must be a valid shell script. The file can be in the current directory or a directory listed in the $PATH variable.
. script
'source' is an alias of the command '.' defined by bash and other shells.
However, executing a script and sourcing a script are two different operations: Difference between "execute" a script and "source" a script.
Share this page on social media:
Questions, comments?
Quick comments
There is no comment yet.