What is the difference between
. script.sh
./script.sh
and
source script.sh
?
What is the difference between
. script.sh
./script.sh
and
source script.sh
?
./script
The above executes the script. When the script is done, any changes that it made to the environment are discarded.
. script
The above sources the script. It is as if the commands had been typed in directly. Any environment changes are kept.
source script
This also sources the script. The source
command is not required by POSIX and therefore is less portable than the shorter .
.