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";; esacResult
child sees production hi 1 usr/bin in PATH
Exercise
Share with child programs.
NAME=valueQuiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.