问题
I run following command in Linux terminal. Can anyone tell me what is the use of parentheses in Linux terminal and following command also ?
$(echo "GET / HTTP/1.0";echo "Host: www.google.com"; echo) | nc www.google.com 80
回答1:
( list )
Placing a list of commands between parentheses causes a subshell environment to be created, and each of the commands in list to be executed in that subshell. Since the list is executed in a subshell, variable assignments do not remain in effect after the subshell completes.
回答2:
Parentheses denote a subshell in bash. In your command, the $() is command substitution and if it is like () is a subshell. Both of them run commands, the difference is what happens to the output.
Unix & Linux Answer
来源:https://stackoverflow.com/questions/45749989/what-is-the-use-of-parentheses-in-linux-command