env
env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
Set each NAME to VALUE in the environment and run COMMAND
Options
--ignore-environment
,-i
-
start with an empty environment
--chdir=<DIR>
,-C <DIR>
-
change working directory to DIR
--null
,-0
-
end each output line with a 0 byte rather than a newline (only valid when printing the environment)
--file=<PATH>
,-f <PATH>
-
read and set variables from a ".env"-style configuration file (prior to any unset and/or set)
--unset=<NAME>
,-u <NAME>
-
remove variable from the environment
--debug
,-v
-
print verbose information for each processing step
--split-string=<S>
,-S <S>
-
process and split S into separate arguments; used to pass multiple arguments on shebang lines
--argv0=<a>
,-a <a>
-
Override the zeroth argument passed to the command being executed. Without this option a default value of
command
is used. --ignore-signal=<SIG>
-
set handling of SIG signal(s) to do nothing
A mere - implies -i. If no COMMAND, print the resulting environment.
Examples
Show the environment:
env
Run a program. Often used in scripts after the shebang (#!) for looking up the path to the program:
env {{program}}
Clear the environment and run a program:
env -i {{program}}
Remove variable from the environment and run a program:
env -u {{variable}} {{program}}
Set a variable and run a program:
env {{variable}}={{value}} {{program}}
Set one or more variables and run a program:
env {{variable1}}={{value}} {{variable2}}={{value}} {{variable3}}={{value}} {{program}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.