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

Is unix a coding language?

649


How can you edit a large file without opening it in unix?

694


What is unix operating system explain various components of unix operating system?

658


How to install unix on windows 10?

747


Is unix still around?

653


Which is a form of interprocess communication in unix?

661


Was unix the first operating system?

660


How to move files from one directory to other in unix?

690


What is home directory in unix?

660


How unix is used?

644


Can you explain what does the kernel do?

714


What unix is mac os based on?

680


Explain what are the unix system calls for i/o?

707


Write a script that prints out date information in this order: time, the day of week, day number, month, year(sample output: 17:34:51 pdt sun 12 feb 2012)

957


What is Thread dump in unix?

765