83
22
Possible Duplicate:
Difference between “a=b” and “export a=b” in bash
It is hard to admit, but I have never really understood what exactly export
does to an environment variable. I know that if I don't export a variable I sometimes can't see it in child processes, but sometimes it seems like I can. What is really going on when I say
export foo=5
and when should I not export a variable?
One common use is to add
export
statements to .bashrc/.bash_profile to create persistent global variables similar to$HOME
. – Evan Plaice – 2016-06-10T05:16:31.523Careful, there is more to this story than initially appears. I invite you to check my answer.
– jasonleonhard – 2017-02-07T03:48:01.153Here's a link to at least one other helpful question on this topic: http://superuser.com/questions/143413/linux-environment-variables/ ... since ironically this question was the first one that popped up on Google for my query on export in bash.
– Ogre Psalm33 – 2011-04-13T18:07:15.7001
Also: http://superuser.com/questions/18988/difference-between-a-b-and-export-a-b-in-bash
– Ogre Psalm33 – 2011-04-13T18:31:08.697