LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   bash script includes? (https://www.linuxquestions.org/questions/linux-software-2/bash-script-includes-227826/)

MIC_Rulz 09-07-2004 03:06 PM

bash script includes?
 
I am fairly new to the bash scripting thing. I've written up a nice script to perform some automated work functions. But as I add to the script it has gotten longer and more difficult to manage.

Other programming types allow the use of include files. Does bash scripting offer such a thing? I tried searching for help on this and have not found anything concrete with what I need. The only include I found was in the manual page and it seems to just immediately execute the file.

I have a number of functions or procedures in the script file and would like to let some of those reside in other files. That way I could keep the menu functions in one file, the file manipulation functions in another, etc.

Any help would be appreciated.

Thanks in advance.

david_ross 09-07-2004 03:15 PM

Welcome to LQ.

Just source the script to bi included - ie:
Code:

#!/bin/bash

# Load the config
. /path/to/config.sh

# Echo some configuration variable
echo $myconfigvar


MIC_Rulz 09-07-2004 05:46 PM

That did the trick. Thank you very much. This makes debugging my scripts a bit easier than before. It also seems to be easier to add functionality to as well.
Maybe someday I will get into writing real programs in a real language.


All times are GMT -5. The time now is 08:34 PM.