Bird
0
0

Which command correctly sets an environment variable in Bash so that it is available to child processes?

easy🧠 Conceptual Q2 of 15
Bash Scripting - Variables
Which command correctly sets an environment variable in Bash so that it is available to child processes?
Aexport MYVAR=value
BMYVAR=value
Clocal MYVAR=value
Dset MYVAR=value
Step-by-Step Solution
Solution:
  1. Step 1: Identify how to set environment variables

    In Bash, to make a variable available to child processes, you must export it using the 'export' command.
  2. Step 2: Check other options

    Assigning without export creates a local variable; 'local' is for function scope; 'set' is for shell options, not variables.
  3. Final Answer:

    export MYVAR=value -> Option A
  4. Quick Check:

    Export command sets environment variables [OK]
Quick Trick: Use 'export' to share variables with child processes [OK]
Common Mistakes:
MISTAKES
  • Forgetting to use 'export' for environment variables
  • Using 'local' outside functions
  • Using 'set' to assign variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes