Sourcing a file in Unix/Linux evaluates the file as a list of commands and executes them in the current context. Most people might have used this technique when updating the configurations for their terminals.
As mentioned above, sourcing a file is to execute a file in the current context, making the changes applicable in the current shell itself. Usually, when we execute a script, a new sub-shell is created and the script is executed there. In this sense, any changes made by the script will remain in the child process. It’s possible to pass these changes further to the additional grandchildren spawned by the child process, but nothing can be copied back to the parent process.
. is a synonym for
. script, but
. scriptis equivalent to