Execute commands from a file in the current shell

. ~/.bashrc

March 16, 2019Julien_Tremblay_McLellan

Explanation

The source or . builtin of Bash do the same thing: execute commands from a file in the current shell.

As a common example use case, imagine that you have installed a new program in your system, and to make it available in your shell, you edit your shell startup file ~/.bashrc, adding the value to the PATH variable. This change to the startup file will affect only new shells, not the current shell. To make it effective in the current shell, you can source the startup file in the current shell, using . ~/.bashrc or source ~/.bashrc, which will execute the commands in it, so you will get the updated value of PATH.

Another example use case is when you have variables or functions defined in a script. To load them into your current shell (or script), you would use . or the source builtin.