As far as I can tell, variable assignment is the same whether it is or is not preceded by “export”. What’s it for?
Share
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.
Exported variables such as
$HOMEand$PATHare available to (inherited by) other programs run by the shell that exports them (and the programs run by those other programs, and so on) as environment variables. Regular (non-exported) variables are not available to other programs.For more information, see the entry for the
exportbuiltin in the GNU Bash manual, and also the sections on command execution environment and environment.Note that non-exported variables will be available to subshells run via
( ... )and similar notations because those subshells are direct clones of the main shell:The subshell can change its own copy of any variable, exported or not, and may affect the values seen by the processes it runs, but the subshell’s changes cannot affect the variable in the parent shell, of course.
Some information about subshells can be found under command grouping and command execution environment in the Bash manual.