What is the difference between a shell variable that is exported and the one that is not exported?

Showing Answers 1 - 14 of 14 Answers

Arun

  • Jul 7th, 2005
 

exported variable is visible to the child processes while the normal variables are not.

  Was this answer useful?  Yes

akebono

  • Jul 27th, 2005
 

export LANG=C 
will make the variable LANG the global variable, put it into the global environment. all other processes can use it. 
 
LANG=C 
will change the value only in the current script. 

  Was this answer useful?  Yes

Sangram

  • Apr 23rd, 2007
 

The Shell variable which is exported would available to all the programs outside the Shell also. And the shell variable which is not exported, would available for that shell or for the shell program only, in which the variable is declared.

  Was this answer useful?  Yes

riteshvado

  • Aug 13th, 2007
 

try this simple script it will clear your concept :-

script a.sh :-
----------
export A=3
B=5
sh b.sh
--------

script b.sh :-
-----------
echo "exported variable $A is :- $A"
echo "Variable $B -- $B "

---------

A persists in b.sh whereas B doesn't.

nitashaa

  • Jul 18th, 2008
 

global variable is created using export command in ksh -
export x='name'
In csh its created using setenv command-
setenv x 'name'
this 'x' variable will be visible in current shell as well as in child shell also.

local variable is created in ksh as x='name'.In csh as -
x 'name'. This variable will be visible only in current shell.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions