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
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
( 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.
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.