() in the Shell of my Shell study notes
IT technology is vast, with gradual learning, in order to do less repetitive learning, it is necessary to record bits and pieces of knowledge of self-study Shell.
Use () in shell:
The command is put into () (command), and the execution of the command is one-time and will not affect the current environment. # (command) opens a child SHELL. After the command is executed, the child SHELL ends its life, and the pid of this child SHELL is equal to the pid of the parent SHELL, and the variables defined by the parent SHELL can be used)
The execution of the command in {command 1; command 2;} will affect the current environment
When the command is put into () and the command is put into {}, multiple commands are executed as a whole, the difference is that () enabling sub-shell does not affect the current environment, {} does not enable sub-shell and will affect the current environment.
IT technology is vast, with gradual learning, in order to do less repetitive learning, it is necessary to record bits and pieces of knowledge of self-study Shell.