Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Created September 24, 2019 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save james2doyle/da6858c8582c2d1b85d474dddf17fda3 to your computer and use it in GitHub Desktop.
Save james2doyle/da6858c8582c2d1b85d474dddf17fda3 to your computer and use it in GitHub Desktop.
This is a trick to load a .ENV file into the session and then evaluate a template file, replacing the variables in it
# read the .env file into the current env
source <(sed -E -n 's/[^#]+/export &/ p' .env)
# we need to escape the $ as ${DOLLAR} in the template,
# so now we can replace it correctly
sudo cat stub.conf.template | DOLLAR='$' envsubst > "${NEW_TEMPLATE_NAME}.conf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment