Source: https://stackoverflow.com/a/45971167/481690
set -a
. ./env.txt
set +a
If env.txt is like:
VAR1=1
VAR2=2
VAR3=3
Explanations -a is equivalent to allexport. In other words, every variable assignment in the shell is exported into the environment (to be used by multiple child processes). More information can be found in the Set builtin documentation:
-a Each variable or function that is created or modified is given the export attribute and marked for export to the environment of subsequent commands.
Using ‘+’ rather than ‘-’ causes these options to be turned off. The options can also be used upon invocation of the shell. The current set of options may be found in $-.