bashunixenvironment-variables

Unset an environment variable for a single command


In Bash, we can set an environment variable for a single command this way:

FOO=bar somecommand

What if we want to unset a variable for a single command?


Solution

  • Technically, they're not environment variables until someone exports them. But you can at least set them to empty:

    FOO= some command
    

    If removing them from the environment is enough, you can use env:

    env -u FOO somecommand