Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set an environment variable using bash_profile, but echo does not return

recently on mac, i set an environment variable so that it is present in a new shell. today opening a shell it no longer appears in a new shell even when i set it. i have been using:

export "AVARIABLE=example" >>~/.bash_profile

which has worked fine until now when i run:

echo $AVARIABLE

i just get a blank line as if it doesn't exist.

this is happening any time i try to set an environment variable permanently now. i can't see what i'm doing wrong?

thanks in advance

like image 640
sphaughton Avatar asked Oct 29 '25 12:10

sphaughton


1 Answers

You are missing an echo in your command. Try this and and then source the ~/.bash_profile:

echo export "AVARIABLE=example" >> ~/.bash_profile

You also have to source the .profile after you make changes to it.

source ~/.bash_profile
like image 90
Amit Verma Avatar answered Nov 01 '25 08:11

Amit Verma