ENV(1) General Commands Manual ENV(1)

envcontrol and print environment

env [-i] [-u name] [name=value] [command [argument...]]

env [-i] [-u name] [name=value] -S command_string

env if specified runs command or command_string, and otherwise prints the environment.

The environment can be modified via the following options:

Ignore the existing environment.
name
Removes the variable named name from the new environment.
name=value
Adds the variable named name with the value value into the new environment, it cannot itself contain the "=" character.

The -S command_string option allows to split a full command passed as a single argument similarly to a shell, useful for shebangs where most Unix-likes do not do argument splitting.
For example:

#!/usr/bin/env -S perl -w -T

If command is invoked, the exit status of env shall be the exit status of command; Otherwise, the env utility shall exit with one of the following values:

0
env completed successfully.
1
An error occurred in env
126
command was found but couldn't be invoked.
127
command wasn't found.

env should be compliant with the IEEE Std 1003.1-2024 (“POSIX.1”) specification.

The -u flag is an extension known to be present in FreeBSD, NetBSD, OpenBSD 7.6, GNU coreutils, BusyBox, ...
The -S flag in an extension known to be present in GNU coreutils and FreeBSD.

Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>

2022-04-19 Linux 6.6.67-gentoo-x86_64