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

Answer Posted / mahendra swain

When we export the variable that will available in subshell
If simply define variable that is only available in current shell.
Example: #var=20
#echo $var
20
If you invoke #sh i.e subshell of bash and try to print that unexported variable valu you will not get that.
sh-2.05b# echo $var-----it does not print the valu of var b'caz still it is in bash shell memory.
Just see the exported variable in shell
[root@dhcppc0 root]# export var1=30
[root@dhcppc0 root]# sh
sh-2.05b# echo $var1
30
I hope you will be enjoy it.

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is file structure in unix?

504


What are states that the page can be in, after causing a page fault?

592


How to find out what processes are running in the background in unix?

559


How to move a background job to forward?

530


What is .sh file in unix?

514






What are the common directory management commands in unix?

571


For which kind of fault the page is checked first?

540


What are data structures that are used for Demand Paging?

569


How do I show only directories in unix?

507


What is the command to connect to remote terminals

528


What is unix computer?

505


Explain the importance of directories in a unix system

645


How to print/display the first line of a file in Unix?

537


What uses unix operating system?

501


Does apple run unix?

483