5

What is the difference between

. script.sh
./script.sh

and

source script.sh

?

0
10
./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 ..

Not the answer you're looking for? Browse other questions tagged or ask your own question.