[oclug] BASH - what does export do?

Kevin Everets flynn at clarkhall.ca
Tue May 24 14:50:02 EDT 2005

On Tue, May 24, 2005 at 02:42:45PM -0400, Andy Civil wrote:

> I've googled for the answer, and the advice always seems to be to use 
> "source" to make it run in the same shell - but that seems like a 
> kludge, and anyway, I don't want to type it a thousand times (it's not 
> like you can put the "source" part in a script, right???!).

Google did provide you the answer, and it is not a kludge.  If you
don't like typing "source" you can just use "." (which is POSIX
standard whereas "source" isn't) as in ". ./somefile" ... and you can
indeed put the "source" part in a script.

> Anyway, if you "source", you don't even need the export - so what does 
> it do???

export will make that contents variable available to subshells and
other commands that you run.  If you don't export them, they won't be
in the environment of those other commands.

> Am I going to be reduced to storing my variable in a file, and using 
> `cat file` with backticks to construct my commands?

I can't imagine why you would do that.


More information about the OCLUG mailing list