Saras Arya Saras Arya - 1 month ago 11
Bash Question

How to add an environmental variable like NODE_ENV from a shell script to .profile?

I am writing a shell script which automates the task of setting up any new EC2 instance. For that purpose, a prerequisite to that is setting up an environmental variable called

NODE_ENV='production'
. Now from a shell script I don't know how to access the profile file to add this line
export NODE_ENV='production'
at the bottom of .profile file?

Answer

To append export NODE_ENV='production' at the bottom of ~/.profile:

echo "export NODE_ENV='production'" >> ~/.profile
Comments