What is the difference between:
export makes the variable available to sub-processes.
means that the variable name is available to any process you run from that shell process. If you want a process to make use of this variable, use
export, and run the process from that shell.
means the variable scope is restricted to the shell, and is not available to any other process. You would use this for (say) loop variables, temporary variables etc.
It's important to note that exporting a variable doesn't make it available to parent processes. That is, specifying and exporting a variable in a spawned process doesn't make it available in the process that launched it.
To illustrate what the other answers are saying:
$ foo="Hello, World" $ echo $foo Hello, World $ bar="Goodbye" $ export foo $ bash bash-3.2$ echo $foo Hello, World bash-3.2$ echo $bar bash-3.2$