What is the output of the following Linux shell (bash) commands?
x=1
{ x=2; }
(x=3)
echo $x
A1
BNothing is printed
C3
D2
Correct answer: D
Explanation
Commands inside braces { } run in the current shell, so x becomes 2, whereas commands inside parentheses ( ) run in a subshell and its changes to variables are lost when it ends, so echo prints 2.