Export command in shell script?

December 2016


Suppose in a program a line is there:


and then
what will happen if i write a command:
export XYZ 


The issue is that scripts run in a private subshell, and therefore don't affect the shell that called them.

If we pretend that we have a script like this:

# Name: test_script 

export OOGA=echo 'ooga' 
export BOOGA=echo 'booga' 

Then we can add it to the current shell by using the source command:

source test_script


Thanks to kupendra for this tip on the forum.

Related :

This document entitled « Export command in shell script? » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.