Recall & Review
beginner
What does
$var mean in bash scripting?It means to get the value stored in the variable named
var. For example, if var holds "hello", then $var will be replaced by "hello".Click to reveal answer
beginner
Why use
${var} instead of just $var?Using
${var} helps bash know exactly where the variable name ends. This is useful when you want to add text right after the variable without spaces. For example, ${var}text clearly separates the variable from the word "text".Click to reveal answer
beginner
What happens if you write
$vartext instead of ${var}text?Bash will look for a variable named
vartext, which might not exist. This can cause errors or unexpected results. Using ${var}text avoids this problem.Click to reveal answer
beginner
How do you print the value of a variable named
name in bash?You can use
echo $name or echo ${name}. Both will print the value stored in name.Click to reveal answer
beginner
Can you use curly braces
{} with variables in all cases?Yes, you can always use
${var} safely. It is especially helpful when you want to add characters immediately after the variable name without confusion.Click to reveal answer
What does
$var do in bash?✗ Incorrect
$var accesses the value stored in the variable named var.
Why use
${var} instead of $var?✗ Incorrect
${var} helps bash know exactly where the variable name ends, especially when adding text right after it.
What happens if you write
$vartext when you meant ${var}text?✗ Incorrect
Bash tries to find a variable named vartext, which may not exist, causing errors or wrong output.
How to print the value of variable
name in bash?✗ Incorrect
echo $name prints the value stored in the variable name.
Is
${var} always safe to use?✗ Incorrect
${var} is always safe and helps avoid confusion in variable names.
Explain how and why to use
$var and ${var} in bash scripting.Think about how bash reads variable names and what happens when you add text right after a variable.
You got /3 concepts.
Describe a common mistake when accessing variables without curly braces and how to fix it.
Focus on how bash interprets variable names when followed by text.
You got /3 concepts.