Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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



share|improve this question
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
up vote 10 down vote accepted

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.

share|improve this answer
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)

share|improve this answer

Put parenthesis around the command:

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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