Recall & Review
beginner
What is a variable in bash scripting?
A variable is a name that holds a value, like a label on a box that stores data you can use later in your script.
Click to reveal answer
beginner
Why do we use variables in scripts?
Variables let us save information once and use it many times, so we don’t have to repeat the same data or type it again.Click to reveal answer
beginner
How do variables help in making scripts easier to change?
If a value is stored in a variable, you only need to change it in one place, and the whole script uses the new value automatically.
Click to reveal answer
beginner
Example: What does this bash code do?
name="Alice" echo "Hello, $name!"
It stores the name 'Alice' in the variable 'name' and then prints 'Hello, Alice!' by reusing the stored value.
Click to reveal answer
intermediate
What happens if you reuse a variable after changing its value?
The script uses the new value stored in the variable, so the output or behavior changes based on the updated data.
Click to reveal answer
What is the main purpose of a variable in bash scripting?
✗ Incorrect
Variables hold data so you can use it multiple times without retyping.
How do you assign the value '5' to a variable named 'count' in bash?
✗ Incorrect
In bash, no spaces are allowed around the '=' sign when assigning variables.
What will this script print?
name="Bob" echo "Hi, $name!" name="Eve" echo "Hi again, $name!"
✗ Incorrect
The variable 'name' changes from 'Bob' to 'Eve', so the second echo uses the new value.
Why is it better to use variables instead of typing the same data multiple times?
✗ Incorrect
Using variables helps avoid errors and makes changing data simple.
Which symbol is used to access the value stored in a variable in bash?
✗ Incorrect
The dollar sign ($) is used before a variable name to get its value.
Explain in your own words why variables are useful in bash scripting.
Think about how you might label and reuse information in daily life.
You got /4 concepts.
Describe what happens when you change the value of a variable and then use it again in a script.
Imagine changing the label on a box and then opening it again.
You got /3 concepts.