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 ...
Ole
  • 707

1 Answers1

3

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.

Stephen Kitt
  • 434,908