[Previous] [Contents] [Next]

env

Set environment for command invocation (POSIX)

Syntax:

env [-i] [name=value]... [command [arguments]]

Deprecated:

env - [name=value]... [command [arguments]]

Options:

-i
Ignore the environment that would otherwise be inherited from the current shell. This restricts the environment for command to that specified by any name=value pairs.
-
(Deprecated) same as -i
name=value
Set the environment variable filename to value and add it to the environment.
command
A command to be invoked.

Description:

The env utility obtains the current environment, modifies it according to its arguments, and executes command with the modified environment. If no command is specified, the resulting environment is displayed.

If you have removed the PATH environment variable from the environment, you must include the path to the command.

Examples:

Start a shell with only the SHELL and PATH environment variables:

    env -i SHELL=/bin/sh PATH=/bin:/usr/bin sh

Start a daemon process with no environment:

    env -i /bin/cron

Exit status:

When a command is specified on the command line, the env utility will attempt to exec() into that command. If the command is successfully launched, the exit status from env will be that of the program it exec()ed into. Otherwise, env will return an exit status as follows:

0
(Assuming no command was specified) the resulting environment was successfully displayed.
>0
An error was present in the command-line parameters supplied or env was unable to launch the command specified on the command line.

[Previous] [Contents] [Next]