Shell Scripting Sourcing a config fileMany programs use external configuration files. Use of external configuration files prevents a user from making changes to a script. Config file is added with the help of source command. If a script is shared in many users and every user need a different configuration file, then instead of changing the script each time simply include the config files. 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 ![]() Script for main.sh ![]() 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. ![]() Look at the above snapshot, on running main.sh file, content of config.sh file is imported via source command.
Next Topicget script options with getopts
|