This content originally appeared on DEV Community and was authored by abdennour
This should work
export $(cat .env | xargs)
But not all time namely if it includes some comments and you are running it with sh (not bash)
Then, mitigate this issue by using instead:
export $(cat .env | sed 's@#.*@@'| tr -d '' | xargs)
This content originally appeared on DEV Community and was authored by abdennour

abdennour | Sciencx (2021-07-18T08:05:37+00:00) Populate env vars from .env file with Shell. Retrieved from https://www.scien.cx/2021/07/18/populate-env-vars-from-env-file-with-shell/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.