{
    "mode": "man",
    "parameter": "ENV",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/man/ENV/json",
    "generated": "2026-10-22T12:59:26Z",
    "synopsis": "env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]",
    "sections": {
        "NAME": {
            "content": "env - run a program in a modified environment\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Set each NAME to VALUE in the environment and run COMMAND.\n\nMandatory arguments to long options are mandatory for short options too.\n",
            "subsections": [
                {
                    "name": "-i --ignore-environment",
                    "content": "start with an empty environment\n",
                    "flag": "-i",
                    "long": "--ignore-environment"
                },
                {
                    "name": "-0 --null",
                    "content": "end each output line with NUL, not newline\n",
                    "flag": "-0",
                    "long": "--null"
                },
                {
                    "name": "-u --unset",
                    "content": "remove variable from the environment\n",
                    "flag": "-u",
                    "long": "--unset"
                },
                {
                    "name": "-C --chdir",
                    "content": "change working directory to DIR\n",
                    "flag": "-C",
                    "long": "--chdir"
                },
                {
                    "name": "-S --split-string",
                    "content": "process  and  split S into separate arguments; used to pass multiple arguments on she‐\nbang lines\n\n--block-signal[=SIG]\nblock delivery of SIG signal(s) to COMMAND\n\n--default-signal[=SIG]\nreset handling of SIG signal(s) to the default\n\n--ignore-signal[=SIG]\nset handling of SIG signal(s) to do nothing\n",
                    "flag": "-S",
                    "long": "--split-string"
                },
                {
                    "name": "--list-signal-handling",
                    "content": "list non default signal handling to stderr\n",
                    "long": "--list-signal-handling"
                },
                {
                    "name": "-v --debug",
                    "content": "print verbose information for each processing step\n\n--help display this help and exit\n",
                    "flag": "-v",
                    "long": "--debug"
                },
                {
                    "name": "--version",
                    "content": "output version information and exit\n\nA mere - implies -i.  If no COMMAND, print the resulting environment.\n\nSIG may be a signal name like 'PIPE', or a signal number like '13'.  Without SIG,  all  known\nsignals  are  included.  Multiple signals can be comma-separated.  An empty SIG argument is a\nno-op.\n",
                    "long": "--version"
                },
                {
                    "name": "Exit status:",
                    "content": "125    if the env command itself fails\n\n126    if COMMAND is found but cannot be invoked\n\n127    if COMMAND cannot be found\n\n-      the exit status of COMMAND otherwise\n"
                }
            ]
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-S/--split-string usage in scripts",
                    "content": "The -S option allows specifying multiple parameters in a script.  Running a script named 1.pl\ncontaining the following first line:\n\n#!/usr/bin/env -S perl -w -T\n...\n\nWill execute perl -w -T 1.pl .\n\nWithout the '-S' parameter the script will likely fail with:\n\n/usr/bin/env: 'perl -w -T': No such file or directory\n\nSee the full documentation for more details.\n"
                },
                {
                    "name": "--default-signal[=SIG] usage",
                    "content": "This option allows setting a signal handler to its default action, which is not possible  us‐\ning  the traditional shell trap command.  The following example ensures that seq will be ter‐\nminated by SIGPIPE no matter how this signal is being handled in  the  process  invoking  the\ncommand.\n\n\nsh -c 'env --default-signal=PIPE seq inf | head -n1'\n"
                }
            ]
        },
        "NOTES": {
            "content": "POSIX's exec(3p) pages says:\n\"many existing applications wrongly assume that they start with certain signals set to\nthe  default  action and/or unblocked.... Therefore, it is best not to block or ignore\nsignals across execs without explicit reason to do so, and  especially  not  to  block\nsignals across execs of arbitrary (not closely cooperating) programs.\"\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Written by Richard Mlynarik, David MacKenzie, and Assaf Gordon.\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "GNU coreutils online help: <https://www.gnu.org/software/coreutils/>\nReport any translation bugs to <https://translationproject.org/team/>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright  ©  2023 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or later\n<https://gnu.org/licenses/gpl.html>.\nThis is free software: you are free to change and redistribute it.  There is NO WARRANTY,  to\nthe extent permitted by law.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "sigaction(2), sigprocmask(2), signal(7)\n\nFull documentation <https://www.gnu.org/software/coreutils/env>\nor available locally via: info '(coreutils) env invocation'\n\nGNU coreutils 9.4                           January 2026                                      ENV(1)",
            "subsections": []
        }
    },
    "summary": "env - run a program in a modified environment",
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "The -S option allows specifying multiple parameters in a script. Running a script named 1.pl containing the following first line: #!/usr/bin/env -S perl -w -T ... Will execute perl -w -T 1.pl . Without the '-S' parameter the script will likely fail with: /usr/bin/env: 'perl -w -T': No such file or directory See the full documentation for more details."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This option allows setting a signal handler to its default action, which is not possible us‐ ing the traditional shell trap command. The following example ensures that seq will be ter‐ minated by SIGPIPE no matter how this signal is being handled in the process invoking the command. sh -c 'env --default-signal=PIPE seq inf | head -n1'"
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "sigaction",
            "section": "2",
            "url": "https://www.chedong.com/phpMan.php/man/sigaction/2/json"
        },
        {
            "name": "sigprocmask",
            "section": "2",
            "url": "https://www.chedong.com/phpMan.php/man/sigprocmask/2/json"
        },
        {
            "name": "signal",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/signal/7/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Show the environment or run a program in a modified environment.",
        "examples": [
            {
                "description": "Show the environment",
                "command": "env"
            },
            {
                "description": "Run a program. Often used in scripts after the shebang (#!) for looking up the path to the program",
                "command": "env {{program}}"
            },
            {
                "description": "Clear the environment and run a program",
                "command": "env {{-i|--ignore-environment}} {{program}}"
            },
            {
                "description": "Remove variable from the environment and run a program",
                "command": "env {{-u|--unset}} {{variable}} {{program}}"
            },
            {
                "description": "Set a variable and run a program",
                "command": "env {{variable}}={{value}} {{program}}"
            },
            {
                "description": "Set one or more variables and run a program",
                "command": "env {{variable1=value variable2=value variable3=value ...}} {{program}}"
            },
            {
                "description": "Run a program under a different name",
                "command": "env {{-a|--argv0}} {{custom_name}} {{program}}"
            }
        ]
    }
}