How to include a file in a bash shell script

I had written few shell scripts for a project. All these scripts were using some common configuration parameters so I decided to put them in a common file and include it in the scripts file so that when I move the script files from the development to the production environment, I have to change the values in one file only.

My configuration file “config.conf” contained variables like:





I included the configuration file in my bash script in the following way:




You can also use the “source” command to include files as below:



source $CONF

The source command can be abbreviated as just a dot as done in the example before.

Leave a Comment

Back to top