If you call env with no arguments, it displays the environment that it received from its parent (presumably the shell).
Arguments of the form
let you add new variables or change the value in existing variables of the environment.
If you specify command, env calls command with the arguments that appear on the command line, passing the accumulated environment to this command. The command is executed directly as a program found in the search PATH and is not interpreted by a shell.
Compare the output of the following two examples which illustrate the use of env:
env foo=bar env env -i foo=bar env
Possible exit status values are:
Failure due to any of the following
Invalid command line argument.
env found command but was unable to invoke it.
env was unable to find command.
- Too many environment variables
The maximum number of environment variables that can be specified in a single env command is limited only by available memory. When exhausted this error will be displayed..
POSIX.2. x/OPEN Portability Guide 4.0. UNIX System V. Windows 7. Windows Server 2008 R2. Windows 8. Windows Server 2012. Windows 10. Windows Server 2016.
printenv on Berkeley UNIX systems has similar functionality.
Normally, MKS KornShell variable names can only contain alphanumeric characters and the underscore (_), and cannot begin with a digit; however, some applications require a shell variable to be set that does not follow these naming conventions. To set such a variable, you can use the env command to insert the normally invalid name directly into the environment block. For example, to run a program that requires a variable named 386 to be set to yes, you can use the following command:
env '386=yes' program
PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC MKS Toolkit 10.1 patch 1 Documentation Build 2.