In addition to functions, we can also create multiple scripts and include them such that we can utilize any shared variables of functions.
Let's say we have a library or utility script that contains a number of functions useful for creating files. This script by itself could be useful or reusable for a number of scripting tasks, so we make it program neutral. Then, we have another script, but this one is dedicated to a single task: performing useless file system operations (IO). In this case, we would have two files:
- io_maker.sh (which includes library.sh and uses library.sh functions)
- library.sh (which contains declared functions, but does not execute them)
The io_maker.sh script simply imports or includes the library.sh script and inherits knowledge of any global variables, functions, and other inclusions. In this manner, io_maker.sh effectively thinks that these other available functions are its own and can execute them as if they were contained within it.