Bash scripting . operator

What does the . operater do if used like

if [[ -f job_specs ]]; then
. job_specs
fi

job_specs is a file

just executing . job_specs returns nothing.

. is also the source command, it runs the script in the current shell rather than in a subshell. You might use this if you want any variables to be kept in the existing shell.

Common example is if you edit your bashrc or similar and want it to take effect without starting a new shell

1 Like