Env |
env is a Unix shell utility for Unix-like operating systems (including Linux). It is used to run another utility in an altered environment. Here, environment means the shell s current set of environment variables and their values. 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 Scripting programming language to launch the correct Interpreter_(computing). In this usage, the environment is typically not changed.
= Example =
Here is the code of a very simple Python_programming_language script:
#!/usr/bin/env python print Hello.
In this example, /usr/bin/env is the full Path_(computing) 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 if multiple versions are installed.
= External Links =
[http://www.gnu.org/software/coreutils/manual/html_node/coreutils_146.html Official GNU Env manual]
[http://www.linuxforum.com/shell/env/31-15.php Alternative manual for Env (from LinuxForum.com)]|
|