Server Administration

An administrator creates a Bash shell variable named BACKUP_DIR, but a script launched from that shell cannot read it from its environment. What should the administrator do before relaunching the script?

Show the answer

Correct answerB. Export the variable from the current shell

AWhy not this: Making a variable read-only prevents reassignment but does not automatically export it.

BWhy this is right: Exporting makes the variable available in the environment of subsequently launched child processes.

CWhy not this: Changing directories changes the working directory, not whether the variable is inherited.

DWhy not this: Quoting affects interpretation of the value; it does not make a shell variable available to child processes.

Exporting a Bash variable makes it available in the environment inherited by subsequently launched processes. Quoting controls how a value is interpreted but does not export the variable.