This will load variables into a BASH SCRIPT from an environment file.
Create an environment file with the following structure. Call it "secrets.env" but it can be called anything!
MY_SECRET="Some Secret"
Then, in your script, include the following:
#!/bin/bash
# Load env file
set -o allexport
[[ -f secrets.env ]] && source secrets.env
set +o allexport
# Now all the variables inside secrets.env are local to the script
echo "Your secret is ${MY_SECRET}"
This content is shared under a Creative Commons Attribution-ShareAlike 4.0 International.