subshell

A child copy of the current shell, created by ( ), by command substitution and by each stage of a pipe.

In more detail

It starts with the same variables, functions and directory, but anything it changes is lost when it exits. (cd dir && make) runs in a subshell so your own directory does not move. The same effect is why a counter incremented inside cmd | while read loses its value after the loop.

Related terms

Taught in

References