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 unix kernel?

478


Describe the term directory?

513


What is path variable in unix?

488


Is windows 10 unix based?

510


Is unix cli or gui?

480






What are the common directory management commands in unix?

577


What is the full form unix?

492


Explain Sticky bit?

574


what is wrong with this interactive shell script?

496


Differentiate between paging and swapping?

518


What does unix like mean?

506


What scheme does the Kernel in Unix System V follow while choosing a swap device among the multiple swap devices?

532


What is the use of unix?

556


Difference between the fork() and vfork() system call?

595


Is windows a unix operating system?

514