Is it possible to set an ENV variable for just one shell command (ie make it expire right after the command executes)?

For example:


I'd like to set my system to use 32bit Python for just this command, then go back to 64bit. Maybe something like



  • The [python] tag should only be used when the question directly relates to Python (e.g. it is written in Python). The same idea applies to tags in general. – Zaz Sep 9 '10 at 20:45
  • I think the [shell] tag should be more specific ([bourne-shell] I assume). – Zaz Sep 9 '10 at 20:46

in Bash, you can do VERSIONER_PYTHON_PREFER_32_BIT=yes winpdb and the env variable is set for the command. Same as you propose but without semi-colon.

  • There's also the "env" command, which exists for exactly this purpose. But yes, if you're already at a shell prompt, it's easier to just to "ENV=foo cmd". – Teddy Oct 24 '09 at 21:40

Run it in a subshell. so (export VERIONSER_PYTHONG_PREFER_32_BIT=YES; winpdb)


Put parenthesis around the command:

(export VARNAME=value; cmd1; cmd2; cmd3)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.