Last active
January 23, 2026 10:17
-
-
Save santaklouse/381c3804a6a237445d389cf19282bdbd to your computer and use it in GitHub Desktop.
Load environment variables from .env file 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
| #!/usr/bin/env bash | |
| [ -f .env ] && export $(cat .env | grep -v '^#' | xargs) | |
| # another variantwith source | |
| # [ -f .env ] && set -a && source .env && set +a | |
| # or | |
| # [ -f .env ] && set -a && . .env && set +a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment