Thursday, February 6, 2025

Loading env file in bash

 If you want to load .env file before running a command in bash, we can use following utility. (Can use the just the command as well.)


14:54:00 harshal@HP:~$ set -a; source ~/.env; set +a; CMD


or


14:55:42 harshal@HP:~$ cat ~/load_dot_env.sh

set -a; source ~/.env; set +a

14:55:47 harshal@HP:~$ source ~/load_dot_env.sh 

14:55:49 harshal@HP:~$ 

 



No comments:

Post a Comment