Bird
0
0

In bash scripting, what is the main reason to use ${var} instead of just $var?

easy🧠 Conceptual Q11 of 15
Bash Scripting - Variables
In bash scripting, what is the main reason to use ${var} instead of just $var?
ATo clearly separate the variable name from surrounding text
BTo declare a new variable
CTo comment out the variable
DTo convert the variable to uppercase
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable access syntax

    In bash, $var accesses the value of a variable named var.
  2. Step 2: Purpose of braces

    Using ${var} helps separate the variable name from other text, avoiding confusion when concatenating.
  3. Final Answer:

    To clearly separate the variable name from surrounding text -> Option A
  4. Quick Check:

    Braces separate variable name from text = A [OK]
Quick Trick: Use braces to avoid mixing variable name with text [OK]
Common Mistakes:
MISTAKES
  • Thinking braces declare variables
  • Using braces to comment variables
  • Assuming braces change variable case

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes