Last active
November 26, 2023 03:44
-
-
Save deviationist/94a061ad8fba1a1a8f41771edf73dc4b to your computer and use it in GitHub Desktop.
Read .env-files in 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
| if [ -f .env ] | |
| then | |
| # export $(cat .env | grep 'DB_HOST' | xargs) # Read specific line | |
| # export $(cat .env | grep 'DB_HOST|DB_USERNAME|DB_PASSWORD' | xargs) # Read specific lines | |
| export $(cat .env | xargs) # Read all lines | |
| else | |
| echo "Error: could not read .env-file" && exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment