Skip to main content
1 of 5
VanagaS
  • 834
  • 8
  • 6

In simple words:

BAZ=jake echo $BAZ

doesn't output anything because, variable substitution takes place first in a command, which means first thing that happens on this command is $BAZ will be replaced with its actual value. Since before execution of this line BAZ doesn't have any value, so echo $BAZ doesnt' output anything. BAZ=jake is part of the command and is only useful, if some process is executed as part of the command line and that process uses this variable BAZ. And the value of BAZ, jake is volatile once the command execution is completed.

For other case:

BAZ=jake; echo $BAZ  

They are two different commands, given in a single line. Its as good as executing one after other.

VanagaS
  • 834
  • 8
  • 6