Bash source Command
source runs the commands in a file inside the current shell, instead of starting a new one.
Variables, functions and aliases the file sets stay available afterwards. A single dot does the same: . settings.sh. This is how changes to ~/.bashrc are loaded without a new terminal.
Load settings from a file
settings.sh contains two variables:
greeting="Hello"
name="Tove"
Run it:
source settings.sh; echo "$greeting, $name"
Hello, Tove
source compared with running the file
settings2.sh contains one line, city="Oslo". Running the file starts a new shell, so its variables are gone when it ends:
bash settings2.sh; echo "City: $city"
City:
. settings2.sh; echo "City: $city"
City: Oslo