-1

I need to run two different regressions requiring 1. two different values of the same env var; 2. two different .bashrc setups; 3. they cannot run concurrently. Can I do something like this:

% export E=value1 ; cp ~/.bashrc.1 ~/.bashrc ; run1 ; export E=value2 ; cp ~/.bashrc.1 ~/.bashrc ; run2

My doubt stems from being unsure whether export E=value2 will take effect for the environment of run2.

2

If you want to be sure then just set it for the executable alone.

% cp ~/.bashrc.1 ~/.bashrc ; E=value1 run1 ; cp ~/.bashrc.1 ~/.bashrc ; E=value2 run2
2

You can easily verify it by yourself:

 export E=a; printenv E; export E=b; printenv E

outputs

a
b

A semicolon separates two statements which happen to be written on one line. The export command sets an environment variable, which stays set until its value changes. If you want the value be changed for just one command, don't use export. Example:

export E=c; E=d printenv E; printenv E

outputs

d
c

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.