Bash & Shell Scripting (50 Qs)•Part 3: Advanced Text Processing & Production Internals (Senior / Lead)
Subshells `(...)` vs Command Grouping `{ ...; }`: Memory isolation and environment variable scope.
senior Levelbash-shellAdvanced Text Processing
In Simple Words:
- Subshell
( cd /tmp && ls ): Spawns a child process. Any variable modifications (export VAR=1) or directory changes (cd) vanish when the subshell terminates, keeping the parent shell clean. - Command Grouping
{ cd /tmp; ls; }: Executes within the current shell process. Variable modifications and directory changes persist in the caller's environment. Requires trailing semicolon before}.