Linux / UNIX source Command Examples

Linux / UNIX source Command Examples

In Linux and Unix, the source command is used to execute commands from a script or configuration file in the current shell. The source command reads the file specified as an argument and executes the commands in the file as if they were typed at the command prompt.

Here are some examples of using the source command:

  1. To execute commands from a script file in the current shell, use the following syntax:
source /path/to/script.sh
‮oS‬urce:www.lautturi.com

This will execute the commands in the script file script.sh in the current shell.

  1. To execute commands from a configuration file in the current shell, use the following syntax:
source /path/to/config.cfg

This will execute the commands in the configuration file config.cfg in the current shell.

  1. To execute multiple scripts or configuration files in the current shell, use the source command multiple times:
source /path/to/script1.sh
source /path/to/script2.sh
source /path/to/config1.cfg
source /path/to/config2.cfg

This will execute the commands in the specified scripts and configuration files in the current shell, in the order they are listed.

The source command is often used to execute configuration files or environment setup.

Created Time:2017-10-29 22:08:56  Author:lautturi