Created
March 22, 2017 13:34
-
Star
(345)
You must be signed in to star a gist -
Fork
(46)
You must be signed in to fork a gist
-
-
Save judy2k/7656bfe3b322d669ef75364a46327836 to your computer and use it in GitHub Desktop.
Parse a .env (dotenv) file directly using BASH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pass the env-vars to MYCOMMAND | |
eval $(egrep -v '^#' .env | xargs) MYCOMMAND | |
# … or ... | |
# Export the vars in .env into your shell: | |
export $(egrep -v '^#' .env | xargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@tgrushka's method is the most reliable one for me when used in scripts.
You can also use it like this if your env vars are in a string: