I have a collection of bash scripts and I want to put some common shell options and variable declarations into a setup.sh script which would get sourced at the beginning of each script.my directory structure is like: includes  setup.sh server_config     build_server_core.sh     install_fail2ban.shBecause the scripts may be run from different computers/enviroments I can't simply use a hardcoded path to the setup.shIs there a one-line command to source a script in a different directory to the running script?
Bash command to source a file in a different directory?
bash
First get the directory of the script itself and then use relative paths like that:DIR=$( cd $( dirname ${BASH_SOURCE[0]} ) && pwd )source $DIR/../includes/setup.shFor more info about finding the correct directory have a look at https://stackoverflow.com/questions/59895