Recall & Review
beginner
What is a local variable in bash scripting?
A local variable is a variable defined inside a script or function that is only accessible within that script or function. It does not affect or get affected by the outside environment.
Click to reveal answer
beginner
What is an environment variable in bash scripting?
An environment variable is a variable that is available system-wide or to all child processes of the shell. It is used to pass information to programs and scripts.
Click to reveal answer
beginner
How do you create a local variable in bash?
Simply assign a value without the export keyword, for example:
myvar="hello". This variable stays local to the current shell or script.Click to reveal answer
beginner
How do you create an environment variable in bash?
Use the
export command before the variable, like export MYVAR="hello". This makes the variable available to child processes.Click to reveal answer
intermediate
Why use environment variables instead of local variables?
Environment variables let you share data with other programs or scripts started from your shell. Local variables are only for temporary use inside one script or shell session.Click to reveal answer
Which command makes a variable available to child processes in bash?
✗ Incorrect
The 'export' command marks a variable to be passed to child processes as an environment variable.
What happens if you define a variable without 'export' in bash?
✗ Incorrect
Without 'export', the variable is local to the current shell or script and not passed to child processes.
Which variable type is accessible by all programs started from the shell?
✗ Incorrect
Environment variables are passed to all child processes and programs started from the shell.
How do you remove an environment variable in bash?
✗ Incorrect
The 'unset' command removes a variable, including environment variables.
Which of these is true about local variables in bash?
✗ Incorrect
Local variables exist only inside the current shell or script and are not exported.
Explain the difference between environment variables and local variables in bash scripting.
Think about where each variable can be accessed.
You got /4 concepts.
Describe how to create and use an environment variable in a bash script.
Focus on the export command and its effect.
You got /4 concepts.