Tech Support Forum banner
Status
Not open for further replies.
1 - 1 of 1 Posts

·
Registered
Joined
·
1 Posts
I was wondering whether there is an equivalent to the #include (used in c programs to import file content) in bash?
You can split up your scripts into files and "include" them with the source aka dot "." operator. The includes do not need to start with "#!/bin/bash", but they must either be in your PATH or have their PATH written exclusively in the main script.

Code:
#!/bin/bash

# A script that includes another script

source My_Other_Script.sh    # include is in $PATH
source /path/to/the/include/My_Other_Other_Script.sh   # explicit PATH
 
1 - 1 of 1 Posts
Status
Not open for further replies.
Top