Example:

We have two files, one is parent file (main.sh) and other is configuration file (config.sh). We have to source this configuration file into our parent file.

Script for config.sh

Shell Scripting Sourcing a config file 1

Script for main.sh

Linux Shell Scripting a config file 2

Look at the above snapshot, we’ve included config.sh file with source command.

Note: We can also use ( . config.sh ) command instead of ( source config.sh ) .

Now on running main.sh file, config.sh file is included.

Shell Scripting Sourcing a config file 3

Look at the above snapshot, on running main.sh file, content of config.sh file is imported via source command.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *