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 ...
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Ole
  • 687
  • 1
  • 10
  • 20

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
  • 411,918
  • 54
  • 1,065
  • 1,164