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)
Print
Share
Comment
Cite
Upload
Translate
APA
abdennour | Sciencx (2024-03-29T12:17:29+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/.
MLA" » Populate env vars from .env file with Shell." abdennour | Sciencx - Sunday July 18, 2021, https://www.scien.cx/2021/07/18/populate-env-vars-from-env-file-with-shell/
HARVARDabdennour | Sciencx Sunday July 18, 2021 » Populate env vars from .env file with Shell., viewed 2024-03-29T12:17:29+00:00,<https://www.scien.cx/2021/07/18/populate-env-vars-from-env-file-with-shell/>
VANCOUVERabdennour | Sciencx - » Populate env vars from .env file with Shell. [Internet]. [Accessed 2024-03-29T12:17:29+00:00]. Available from: https://www.scien.cx/2021/07/18/populate-env-vars-from-env-file-with-shell/
CHICAGO" » Populate env vars from .env file with Shell." abdennour | Sciencx - Accessed 2024-03-29T12:17:29+00:00. https://www.scien.cx/2021/07/18/populate-env-vars-from-env-file-with-shell/
IEEE" » Populate env vars from .env file with Shell." abdennour | Sciencx [Online]. Available: https://www.scien.cx/2021/07/18/populate-env-vars-from-env-file-with-shell/. [Accessed: 2024-03-29T12:17:29+00:00]
rf:citation » Populate env vars from .env file with Shell | abdennour | Sciencx | https://www.scien.cx/2021/07/18/populate-env-vars-from-env-file-with-shell/ | 2024-03-29T12:17:29+00:00
https://github.com/addpipe/simple-recorderjs-demo