2

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

dlmeetei
  • 9,905
  • 3
  • 31
  • 38
njoe
  • 39
  • 1
  • 2

2 Answers2

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.

Yuriy Zhigulskiy
  • 1,382
  • 9
  • 11
  • Also, any other environment changes, such as a `cd` command, are localized to the context of the subshell, and disappear when the subshell is exited. – tripleee Jun 18 '19 at 04:59
1

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

Abhilash KK
  • 448
  • 5
  • 19