- Env
env is a shell command for
Unix andUnix-like operating system s. It is used to either print a list ofenvironment variable s or run another utility in an altered environment without having to modify the currently existing environment. Using env, variables may be added or removed, and the values of existing variables may be changed.In practice, env has another common use. It is often used by
shell script s to launch the correct interpreter. In this usage, the environment is typically not changed.Examples
To clear the environment for a new shell:
To launch the
X Window applicationxcalc and have it appear on a different display:Here is the code of a very simple Python script:
In this example, /usr/bin/env is the full path of the env command. The environment is not altered.
Note that it is possible to specify the interpreter without using env, by giving the full path of the python interpreter. A problem with that approach is that on different computer systems, the exact path may be different. By instead using env as in the example, the interpreter is searched for and located at the time the script is run. This makes the script more portable, but also increases the risk that the wrong interpreter is selected because it searches for a match in every directory on the executable search path.
External links
* [http://www.gnu.org/software/coreutils/manual/html_node/env-invocation.html env] -- manual page from
GNU coreutils .
*man|1|env|Linux| run a program in a modified environment
Wikimedia Foundation. 2010.