env — Display or set environment variables for a process
Format
- env [–i] [variable=value …] [command argument …]
- env [–] [variable=value …] [command argument …]
Description
If you enter env with no arguments, it displays the environment variable that it received from its parent (presumably the shell).
Arguments of the form variable=value let you add new environment variables or change the value of existing environment variables.
If you specify command, env calls command with the arguments specified with the argument argument that appear on the command line, passing the accumulated environment variable to this command. The command is run directly as a program found in the search path, and is not interpreted by a shell.
In a double-byte locale, environment variable values can contain double-byte characters. The equal sign (=) must be single byte.
Options
- –i
- Specifies that the environment variable inherited by env not be used.
- –
- Specifies that the environment variable inherited by env not be used.
Examples
- Compare the output of the following two examples:
env foo=bar env env –i foo=bar env
- Compare the output of the following example:
env - echo $PATH .:/usr/lpp/Printsrv/bin:/bin:/usr/sbin
Localization
- LANG
- LC_ALL
- LC_CTYPE
- LC_MESSAGES
- NLSPATH
See Localization for more information.
Exit values
- 0
- Successful completion.
- 1
- Failure due to any of the following situations:
- Not enough memory
- Name is too long
- 2
- Incorrect command-line argument.
- 126
- env found command but could not invoke it.
- 127
- env could not find command.
Portability
POSIX.2, X/Open Portability Guide, UNIX System V.
printenv on Berkeley UNIX systems works like env.
Related information
env, sh