Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
export $(cat .env | xargs)
Copy link

miedza commented Sep 29, 2022

export $(awk -F= '{output=output" "$1"="$2} END {print output}' aaa.env)

Copy link

bergpb commented Dec 9, 2022

[ ! -f .env ] || export $(grep -v '^#' .env | xargs)

Sweet, works like a charm for me, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment