How to use your .env file in bash

Sample .env

mysql_host="localhost"
mysql_user=user_1

Sample bash

#!/bin/bash
eval $(cat .env | sed 's/^/export /')
echo $mysql_host    

Use eval $(cat .env | sed 's/^[^$]/export /') for allowing blank lines in .env file

source