What starts with a new subshell in Bash?

Are there any actions in Bash other than pipes and command substitution that start a new subshell?

+4
source share
2 answers

Entering a chain of commands in parens ( ( ... ) ) also launches a new subshell.

 ( cd /tmp ; pwd ) ; pwd 
+7
source

Each running shell script is essentially a subprocess (child process) of the parent shell.

A shell script can itself run subprocesses. These subshells allow parallel processing of the script, actually performing multiple subtasks at the same time.

let's say you have a test.sh script. After starting, if you run the command

 ps -ef|grep -i test.sh 

you will see that it works with different PIDs

In general, an external command in a script issues a subprocess / subclass

0
source

All Articles