Question #67

Author: admin
tags: Linux  
What is the difference between grouping commands using curly braces {} and parentheses ()?
There are no differences, both options are the same.
Commands in parentheses are executed in a subshell.
Commands in curly brackets always return the exit code 0.
Commands in curly brackets cannot use command substitution syntax ${}.
Commands cannot be grouped with curly brackets.
Commands cannot be grouped with parentheses.
planet=Earth
{
  continent=Antarctica
  echo $planet
}
echo $continent
planet=Earth
(
  continent=Antarctica
  echo $planet
)
echo $continent
In the second case, the value of the variable continent will not be printed, because it was created in the subshell.
Rate the difficulty of the question:
easyhard