I am trying to understand the use of export command.
I tried using man export, but there is no manual for this command.
Can anyone please help me out understanding the use of export in UNIX?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you execute a program the child program inherits its environment variables from the parent. For instance if
$HOMEis set to/rootin the parent then the child’s$HOMEvariable is also set to/root.This only applies to environment variable that are marked for export. If you set a variable at the command-line like
That variable will not be visible in child processes. Not unless you export it:
You can combine these two statements into a single one in bash (but not in old-school sh):
Here’s a quick example showing the difference between exported and non-exported variables. To understand what’s happening know that
sh -ccreates a child shell process which inherits the parent shell’s environment.Note: To get help on shell built-in commands use
help export. Shell built-ins are commands that are part of your shell rather than independent executables like/bin/ls.