GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Operating System  >  Shell Scripting
Go To First  |  Previous Question  |  Next Question 
 Shell Scripting  |  Question 8 of 47    Print  
What is the difference between a shell variable that is exported and the one that is not exported?

  
Total Answers and Comments: 6 Last Update: July 18, 2008   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: riteshvado
 

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.



Above answer was rated as good by the following members:
csprusty, shahhardik, abhimishraoist, pmchaurasia
July 07, 2005 13:09:36   #1  
Arun        

RE: What is the difference between a shell variable that is exported and the one that is not exported?
exported variable is visible to the child processes while the normal variables are not.
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
July 27, 2005 15:36:48   #2  
akebono        

RE: What is the difference between a shell variable that is exported and the one that is not exported?
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.

 
Is this answer useful? Yes | No
April 23, 2007 00:50:45   #3  
Sangram        

RE: What is the difference between a shell variable th...
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.
 
Is this answer useful? Yes | No
April 27, 2007 17:53:46   #4  
narhars2004 Member Since: April 2007   Contribution: 1    

RE: What is the difference between a shell variable th...

Export is to set the vaibales globally
No export u are using the variables locally .


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
August 13, 2007 05:26:49   #5  
riteshvado Member Since: December 2006   Contribution: 5    

RE: What is the difference between a shell variable th...

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.


 
Is this answer useful? Yes | NoAnswer is useful 3   Answer is not useful 0Overall Rating: +3    
July 18, 2008 04:46:49   #6  
nitashaa Member Since: July 2008   Contribution: 9    

RE: What is the difference between a shell variable that is exported and the one that is not exported?
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.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape