0

I'm wondering whether this (From https://www.digitalocean.com/community/tutorials/how-to-read-and-set-environmental-and-shell-variables-on-a-linux-vps):

env VAR1="blahblah" command_to_run command_options

Is the same thing as:

VAR1="blahblah"
export VAR1
command_to_run ...
2

No, it's not the same.

env VAR1="blahblah" command_to_run command_options

runs command_to_run with VAR1="blahblah" in its environment; the containing shell's environment isn't affected.

VAR1="blahblah"
export VAR1
command_to_run

adds VAR1="blahblah" to the shell's environment and makes it available for all subsequent commands, including command_to_run.

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.