Grouping commands in a subshell

( <LIST> )

The list <LIST> is executed in a separate shell - a subprocess. No changes to the environment (variables etc…) are reflected in the "main shell".

Execute a command in a different directory.

echo "$PWD"
( cd /usr; echo "$PWD" )
echo "$PWD" # Still in the original directory.

  • The subshell compound command is specified by POSIX.
  • Avoid ambiguous syntax.

(((1+1))) # Equivalent to: (( (1+1) ))

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
You could leave a comment if you were logged in.
  • syntax/ccmd/grouping_subshell.txt
  • Last modified: 2013/01/14 19:21
  • by ormaaj