What does the 'export' command do?

command, environment-variables, shell, unix

Solution

`export` in `sh` and related shells (such as Bash), marks an environment variable to be exported to child-processes, so that the child inherits them.

`export` is defined in POSIX:

The shell shall give the export attribute to the variables corresponding to the specified names, which shall cause them to be in the environment of subsequently executed commands. If the name of a variable is followed by = word, then the value of that variable shall be set to word.

Problem

I happen to run some commands blindly, in order to get things done. I started to work with Jenkins recently, and then I had to use this `export` command to run the Jenkins WAR archive. What does the `export` command do in general, and why do we need to run this command, while running Jenkins (after the Jenkins home is set)?

Original source

Related problems