Tsallaka zuwa abun ciki
Justice Tech School

Subshells

( ) runs commands in a child shell. Changes inside do not affect the parent.

Example
x=1
( x=2; echo "inner $x" )
echo "outer $x"
(cd /tmp && pwd)
pwd >/dev/null

Result

inner 2
outer 1
/tmp

Exercise

Group in a subshell.

 x=2 )

Quiz Test

Does a subshell change the parent variables?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.