Bash - Subshell ()

> Procedural Languages > Bash Shell and (Unix|Linux) Utilities (XCU)

1 - About

Subshell (a shell started from a shell with its own scope).

Advertising

3 - Example

  • $(command) will capture the standard stream.
  • (command) will execute without capturing the standard stream.
foo() {
    >&2 echo "std error";
    echo "std out";
}
 
echo $(foo)
std error
std out