Skip to main content
typo and formatting
Source Link
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 that, the first thing that happens on this command line is $BAZ will be replaced with whatever actual value that variable BAZ was defined with, earlier (if any). Mind that this happens even before shell considers BAZ=jake on the same command line. 

Prior to execution of our command, since BAZ doesn't have any value assigned and since BAZ=jake is considered only after $BAZ is resolved, $BAZ doesn't resolve to any value. And hence echo $BAZ doesn't output anything.

BAZ=jake is only part of the given command (shell will not consider/set it as an environment variable) and this. This is mostly useful, if some process, that is executed as part of the same command line, uses this variable BAZ. And theThe value of BAZ, jake is volatile once the command execution is completed.

For example: ]# LD_LIBRARY_PATH="new_path" ldconfig, where ldconfig command internally refers to variable LD_LIBRARY_PATH and there is no variable expansion in this command line unlike above.

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.

In simple words:

BAZ=jake echo $BAZ

doesn't output anything because, variable substitution takes place first in a command. Which means that, the first thing that happens on this command line is $BAZ will be replaced with whatever actual value that variable BAZ was defined with, earlier (if any). Mind that this happens even before shell considers BAZ=jake on the same command line. Prior to execution of our command, since BAZ doesn't have any value assigned and since BAZ=jake is considered only after $BAZ is resolved, $BAZ doesn't resolve to any value. And hence echo $BAZ doesn't output anything.

BAZ=jake is only part of the given command (shell will not consider/set it as an environment variable) and this is mostly useful, if some process, that is executed as part of the same command line, uses this variable BAZ. And the value of BAZ, jake is volatile once the command execution is completed.

For example: ]# LD_LIBRARY_PATH="new_path" ldconfig, where ldconfig command internally refers to variable LD_LIBRARY_PATH and there is no variable expansion in this command line unlike above.

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.

In simple words:

BAZ=jake echo $BAZ

doesn't output anything because, variable substitution takes place first in a command. Which means that, the first thing that happens on this command line is $BAZ will be replaced with whatever actual value that variable BAZ was defined with, earlier (if any). Mind that this happens even before shell considers BAZ=jake on the same command line. 

Prior to execution of our command, since BAZ doesn't have any value assigned and since BAZ=jake is considered only after $BAZ is resolved, $BAZ doesn't resolve to any value. And hence echo $BAZ doesn't output anything.

BAZ=jake is only part of the given command (shell will not consider/set it as an environment variable). This is mostly useful, if some process executed as part of the same command line, uses this variable BAZ. The value of BAZ, jake is volatile once the command execution is completed.

For example: ]# LD_LIBRARY_PATH="new_path" ldconfig, where ldconfig command internally refers to variable LD_LIBRARY_PATH and there is no variable expansion in this command line unlike above.

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.

fixed a typo
Source Link
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. Which means that, the first thing that happens on this command line is $BAZ will be replaced with itswhatever actual value that variable BAZ was defined with, earlier (if any). SinceMind that this happens even before shell considers BAZ=jake on the same command line. Prior to execution of this lineour command, since BAZ doesn't have any value assigned and since BAZ=jake is considered only after $BAZ is resolved, so $BAZ doesn't resolve to any value. And hence echo $BAZ doesnt'doesn't output anything.

BAZ=jake is only part of the given command (shell will not consider/set it as an environment variable) and this is mostly useful, if some process, that is executed as part of the same command line, uses this variable BAZ. And the value of BAZ, jake is volatile once the command execution is completed.

For example: ]# LD_LIBRARY_PATH="new_path" ldconfig, where ldconfig command internally refers to variable LD_LIBRARY_PATH and there is no variable expansion in this command line unlike above.

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.

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 only part of the given command (shell will not consider/set it as an environment variable) and this is mostly useful, if some process, that is executed as part of the same command line, uses this variable BAZ. And the value of BAZ, jake is volatile once the command execution is completed.

For example: ]# LD_LIBRARY_PATH="new_path" ldconfig, where ldconfig command internally refers to variable LD_LIBRARY_PATH and there is no variable expansion in this command line unlike above.

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.

In simple words:

BAZ=jake echo $BAZ

doesn't output anything because, variable substitution takes place first in a command. Which means that, the first thing that happens on this command line is $BAZ will be replaced with whatever actual value that variable BAZ was defined with, earlier (if any). Mind that this happens even before shell considers BAZ=jake on the same command line. Prior to execution of our command, since BAZ doesn't have any value assigned and since BAZ=jake is considered only after $BAZ is resolved, $BAZ doesn't resolve to any value. And hence echo $BAZ doesn't output anything.

BAZ=jake is only part of the given command (shell will not consider/set it as an environment variable) and this is mostly useful, if some process, that is executed as part of the same command line, uses this variable BAZ. And the value of BAZ, jake is volatile once the command execution is completed.

For example: ]# LD_LIBRARY_PATH="new_path" ldconfig, where ldconfig command internally refers to variable LD_LIBRARY_PATH and there is no variable expansion in this command line unlike above.

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.

fixed a typo
Source Link
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 only part of the given command (shell will not consider/set it as an environment variable) and this is mostly useful, if some process, that is executed as part of the same command line, uses this variable BAZ. And the value of BAZ, jake is volatile once the command execution is completed.

For example: ]# LD_LIBRARY_PATH="new_path" ldconfig, where ldconfig command internally refers to variable LD_CONFIG_PATHLD_LIBRARY_PATH and there is no variable expansion in this command line unlike above.

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.

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 only part of the given command (shell will not consider/set it as an environment variable) and this is mostly useful, if some process, that is executed as part of the same command line, uses this variable BAZ. And the value of BAZ, jake is volatile once the command execution is completed.

For example: ]# LD_LIBRARY_PATH="new_path" ldconfig, where ldconfig command internally refers to variable LD_CONFIG_PATH and there is no variable expansion in this command line unlike above.

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.

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 only part of the given command (shell will not consider/set it as an environment variable) and this is mostly useful, if some process, that is executed as part of the same command line, uses this variable BAZ. And the value of BAZ, jake is volatile once the command execution is completed.

For example: ]# LD_LIBRARY_PATH="new_path" ldconfig, where ldconfig command internally refers to variable LD_LIBRARY_PATH and there is no variable expansion in this command line unlike above.

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.

fixed a typo
Source Link
VanagaS
  • 834
  • 8
  • 6
Loading
Source Link
VanagaS
  • 834
  • 8
  • 6
Loading