How can I read an .env file and set the variables as bash variables? Currently, I'm able to read it and export them as environment variables.
If the file contains the variables:
DB_NAME=mydb
DB_PASSWORD=abcd1234Then, DB_NAME and DB_PASSWORD will be bash variables and they will contain the respective values.
1 Answer
If a text file is formatted as
DB_NAME=mydb
DB_PASSWORD=abcd1234then these variables can be set in the current bash shell simply by sourcing the file as:
source my_custom.env 3