Tsallaka zuwa abun ciki
Justice Tech School

Environment Variables

export makes a variable visible to child programs. env lists them, and VAR=value command sets one for a single command. PATH tells the shell where to find programs.

Example
export APP_ENV=production
bash -c 'echo "child sees $APP_ENV"'
GREETING=hi bash -c 'echo $GREETING'
echo "$GREETING"
env | grep -c APP_ENV
case ":$PATH:" in *:/usr/bin:*) echo "usr/bin in PATH";; esac

Result

child sees production
hi

1
usr/bin in PATH

Exercise

Share with child programs.

 NAME=value

Quiz Test

What does export do?

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