Skip to main content
p. 312

11.12 Including Other Files in Scripts

If you need to include code from another file in your shell script, use the dot (.) operator. For example, this runs the commands in the file config.sh:

. config.sh

This method of inclusion is also called sourcing a file and is useful for reading variables (for example, in a shared configuration file) and other kinds of definitions. This is not the same as executing another script; when you run a script (as a command), it starts in a new shell, and you can’t get anything back other than the output and the exit code.