The export builtin automatically exports to the environment of child processes. For example, Create the variable called vech, and give it a value "Bus":
Display the value of a variable with echo, enter:
Now, start a new shell instance, enter:
Now, display back the value of a variable vech with echo, enter:
You will get an empty line as the variable vech is not exported to new process. To make the variable known to child processes, use the export command. Try the following example at a console or terminal:
export backup="/nas10/mysql" echo "Backup dir $backup" bash echo "Backup dir $backup"
By default all user defined variables are local. They are not exported to new processes. Use export command to export variables and functions to child processes. If no variable names or function names are given, or if the -p option is given, a list of all names that are exported in this shell is printed. An argument of -n says to remove the export property from subsequent NAMEs.
Please note that system environment variables are passed to new processes.