Load .env file in Bash
There is an easy way to load an .env
file in #bash. Let’s have example .env
file:
example=valueexample2=value
then you can read this file in #bash like this:
#!/usr/bin/env bash
set -o allexport[[ -f .env ]] && source .envset +o allexport
Warning: All existing variables are overridden by .env
content.