In POSIX-compliant shells such as bash, a shell variable is only visible within the current shell by default. To make it part of the environment so that child processes (subshells) inherit it, the export builtin command is used, referencing the variable name without a leading $ (e.g., export VARIABLE). This marks the variable for export to the environment of subsequently executed commands. The set command is used for setting positional parameters or shell options, not for exporting variables, and env is used to run a command in a modified environment or display the current environment, not to export a variable from the current shell.
Community Discussion