mirror of
https://github.com/rawiriblundell/wiki.bash-hackers.org
synced 2024-12-25 14:10:42 +01:00
849 B
849 B
====== Grouping commands in a subshell ======
===== Synopsis =====
( )
===== Description ===== The list '''' is executed in a separate shell - a subprocess. No changes to the environment (variables etc...) are reflected in the "main shell".
===== Examples =====
Execute a command in a different directory.
echo "$PWD"
( cd /usr; echo "$PWD" )
echo "$PWD" # Still in the original directory.
===== Portability considerations =====
- The subshell compound command is specified by POSIX.
- Avoid ambiguous syntax.
(((1+1))) # Equivalent to: (( (1+1) ))
===== See also =====