Bash & Shell Scripting (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What is a Subshell in Bash and how do parentheses `(...)` differ from braces `{...}`?
senior LevelSystem Design
In Simple Words:
- Parentheses
( ... ): Executes commands inside a child subshell process. Environment variable changes inside the parentheses do not affect the parent shell:(cd /tmp && make build)-> The parent script remains in the original directory! - Braces
{ ...; }: Executes commands inside the current shell environment. Variables and directory changes persist in the parent script.